diff options
Diffstat (limited to 'lib/system/sysstr.nim')
-rw-r--r-- | lib/system/sysstr.nim | 12 |
1 files changed, 11 insertions, 1 deletions
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.} |