* Fixes #7079 * Fix handling of neg zero during constant folding
This commit is contained in:
parent
b5538990a2
commit
94038545be
4 changed files with 31 additions and 11 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue