summary refs log tree commit diff stats
path: root/compiler/rodutils.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rodutils.nim')
-rw-r--r--compiler/rodutils.nim16
1 files changed, 10 insertions, 6 deletions
diff --git a/compiler/rodutils.nim b/compiler/rodutils.nim
index 0456e9349..0d9c7112f 100644
--- a/compiler/rodutils.nim
+++ b/compiler/rodutils.nim
@@ -8,18 +8,22 @@
 #
 
 ## Serialization utilities for the compiler.
-import strutils
+import strutils, math
 
 proc c_snprintf(s: cstring; n:uint; frmt: cstring): cint {.importc: "snprintf", header: "<stdio.h>", nodecl, varargs.}
 
 proc toStrMaxPrecision*(f: BiggestFloat, literalPostfix = ""): string =
-  if f != f:
+  case classify(f)
+  of fcNaN:
     result = "NAN"
-  elif f == 0.0:
+  of fcNegZero:
+    result = "-0.0" & literalPostfix
+  of fcZero:
     result = "0.0" & literalPostfix
-  elif f == 0.5 * f:
-    if f > 0.0: result = "INF"
-    else: result = "-INF"
+  of fcInf:
+    result = "INF"
+  of fcNegInf:
+    result = "-INF"
   else:
     when defined(nimNoArrayToCstringConversion):
       result = newString(81)