summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/core/typeinfo.nim4
-rw-r--r--lib/pure/complex.nim7
-rw-r--r--lib/system/hti.nim6
-rw-r--r--lib/system/sysstr.nim12
4 files changed, 20 insertions, 9 deletions
diff --git a/lib/core/typeinfo.nim b/lib/core/typeinfo.nim
index 0046924a1..c3ff66591 100644
--- a/lib/core/typeinfo.nim
+++ b/lib/core/typeinfo.nim
@@ -66,9 +66,9 @@ type
   ppointer = ptr pointer
   pbyteArray = ptr array[0.. 0xffff, int8]
 
-  TGenSeq = object
+  TGenericSeq {.importc.} = object
     len, space: int
-  PGenSeq = ptr TGenSeq
+  PGenSeq = ptr TGenericSeq
 
 const
   GenericSeqSize = (2 * sizeof(int))
diff --git a/lib/pure/complex.nim b/lib/pure/complex.nim
index c844c1fa2..8577bf7a1 100644
--- a/lib/pure/complex.nim
+++ b/lib/pure/complex.nim
@@ -365,9 +365,9 @@ proc polar*(z: Complex): tuple[r, phi: float] =
   result.phi = phase(z)
 
 proc rect*(r: float, phi: float): Complex =
-  ## Returns the complex number with poolar coordinates `r` and `phi`.
+  ## Returns the complex number with polar coordinates `r` and `phi`.
   result.re = r * cos(phi)
-  result.im = sin(phi)
+  result.im = r * sin(phi)
 
 
 proc `$`*(z: Complex): string =
@@ -438,5 +438,6 @@ when isMainModule:
   assert( arccoth(a) =~ arctanh(1/a) )
 
   assert( phase(a) == 1.1071487177940904 )
-  assert( polar(a) =~ (2.23606797749979, 1.1071487177940904) )
+  var t = polar(a)
+  assert( rect(t.r, t.phi) =~ a )
   assert( rect(1.0, 2.0) =~ (-0.4161468365471424, 0.9092974268256817) )
diff --git a/lib/system/hti.nim b/lib/system/hti.nim
index 7dee054ac..aff0c0e6f 100644
--- a/lib/system/hti.nim
+++ b/lib/system/hti.nim
@@ -11,7 +11,7 @@ when declared(NimString):
   # we are in system module:
   {.pragma: codegenType, compilerproc.}
 else:
-  {.pragma: codegenType.}
+  {.pragma: codegenType, importc.}
 
 type 
   # This should be he same as ast.TTypeKind
@@ -65,7 +65,7 @@ type
     tyBigNum,
 
   TNimNodeKind = enum nkNone, nkSlot, nkList, nkCase
-  TNimNode {.codegenType, final.} = object
+  TNimNode {.codegenType.} = object
     kind: TNimNodeKind
     offset: int
     typ: ptr TNimType
@@ -78,7 +78,7 @@ type
     ntfAcyclic = 1,    # type cannot form a cycle
     ntfEnumHole = 2    # enum has holes and thus `$` for them needs the slow
                        # version
-  TNimType {.codegenType, final.} = object
+  TNimType {.codegenType.} = object
     size: int
     kind: TNimKind
     flags: set[TNimTypeFlag]
diff --git a/lib/system/sysstr.nim b/lib/system/sysstr.nim
index 9d9cc0070..cfbc24f0c 100644
--- a/lib/system/sysstr.nim
+++ b/lib/system/sysstr.nim
@@ -264,7 +264,17 @@ proc nimFloatToStr(f: float): string {.compilerproc.} =
     buf[n] = '.'
     buf[n+1] = '0'
     buf[n+2] = '\0'
-  result = $buf
+  # On Windows nice numbers like '1.#INF', '-1.#INF' or '1.#NAN' are produced.
+  # We want to get rid of these here:
+  if buf[n-1] == 'N':
+    result = "nan"
+  elif buf[n-1] == 'F':
+    if buf[0] == '-':
+      result = "-inf"
+    else:
+      result = "inf"
+  else:
+    result = $buf
 
 proc strtod(buf: cstring, endptr: ptr cstring): float64 {.importc,
   header: "<stdlib.h>", noSideEffect.}