summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2017-05-17 14:57:06 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-05-17 15:57:06 +0200
commit06415eb69dd6002ac658ebbaaf334ae886a310a6 (patch)
tree14f2c04b991ea7cd9fa0f8c156c3510b5267fc7a /compiler
parent943aaecbe751f76b53f1a8332b2bee1fa3a00fb2 (diff)
downloadNim-06415eb69dd6002ac658ebbaaf334ae886a310a6.tar.gz
Fixes #5821 (float32 literal comparison issue) (#5825)
* Remove processing hints for async procs.
* Fixes #5821.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgexprs.nim4
-rw-r--r--compiler/rodutils.nim6
2 files changed, 6 insertions, 4 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index b03f7c5aa..d244153db 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -78,8 +78,10 @@ proc genLiteral(p: BProc, n: PNode, ty: PType): Rope =
                         [p.module.tmpBase, rope(id)])
     else:
       result = makeCString(n.strVal)
-  of nkFloatLit..nkFloat64Lit:
+  of nkFloatLit, nkFloat64Lit:
     result = rope(n.floatVal.toStrMaxPrecision)
+  of nkFloat32Lit:
+    result = rope(n.floatVal.toStrMaxPrecision("f"))
   else:
     internalError(n.info, "genLiteral(" & $n.kind & ')')
     result = nil
diff --git a/compiler/rodutils.nim b/compiler/rodutils.nim
index d24e8f560..77f7c844f 100644
--- a/compiler/rodutils.nim
+++ b/compiler/rodutils.nim
@@ -12,17 +12,17 @@ import strutils
 
 proc c_sprintf(buf, frmt: cstring) {.importc: "sprintf", header: "<stdio.h>", nodecl, varargs.}
 
-proc toStrMaxPrecision*(f: BiggestFloat): string =
+proc toStrMaxPrecision*(f: BiggestFloat, literalPostfix = ""): string =
   if f != f:
     result = "NAN"
   elif f == 0.0:
-    result = "0.0"
+    result = "0.0" & literalPostfix
   elif f == 0.5 * f:
     if f > 0.0: result = "INF"
     else: result = "-INF"
   else:
     var buf: array[0..80, char]
-    c_sprintf(buf, "%#.16e", f)
+    c_sprintf(buf, "%#.16e" & literalPostfix, f)
     result = $buf
 
 proc encodeStr*(s: string, result: var string) =