Files
Nim/tests/float/tfloat8.nim
Arne Döring b2c6db97f9 printing float values will have one more digit. (#13276) [backport]
* printing float values will have one more digit. Fixes #13196
2020-02-07 17:10:25 +01:00

20 lines
410 B
Nim

discard """
disabled: windows
"""
{.passL: "-lm".} # not sure how to do this on windows
import strutils
proc nextafter(a,b: float64): float64 {.importc: "nextafter", header: "<math.h>".}
var myFloat = 2.5
for i in 0 .. 100:
let newFloat = nextafter(myFloat, Inf)
let oldStr = $myFloat
let newStr = $newFloat
doAssert parseFloat(newStr) == newFloat
doAssert oldStr != newStr
myFloat = newFloat