summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/system/jssys.nim4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim
index 5f18f01cb..64c766482 100644
--- a/lib/system/jssys.nim
+++ b/lib/system/jssys.nim
@@ -495,11 +495,13 @@ proc negInt64(a: int64): int64 {.compilerproc.} =
 
 proc nimFloatToString(a: float): cstring {.compilerproc.} =
   ## ensures the result doesn't print like an integer, i.e. return 2.0, not 2
+  # print `-0.0` properly
   asm """
     function nimOnlyDigitsOrMinus(n) {
       return n.toString().match(/^-?\d+$/);
     }
-    if (Number.isSafeInteger(`a`)) `result` =  `a`+".0"
+    if (Number.isSafeInteger(`a`))
+      `result` = `a` === 0 && 1 / `a` < 0 ? "-0.0" : `a`+".0"
     else {
       `result` = `a`+""
       if(nimOnlyDigitsOrMinus(`result`)){