This commit is contained in:
Fredrik Høisæther Rasch 2017-10-27 11:34:57 +02:00 • committed by Andreas Rumpf
commit 8c94a00e02
2 changed files with 28 additions and 1 deletions

22
tests/float/tfloatnan.nim Normal file
View file

@ -0,0 +1,22 @@
discard """
file: "tfloatnan.nim"
output: '''Nim: nan
Nim: nan (float)
C: nan (float)
Nim: nan (double)
C: nan (double)
'''
"""
proc printf(formatstr: cstring): int {.importc: "printf", varargs, header: "<stdio.h>".}
let f = NaN
echo "Nim: ", f
let f32: float32 = NaN
echo "Nim: ", f32, " (float)"
discard printf("C: %f (float)\n", f32)
let f64: float64 = NaN
echo "Nim: ", f64, " (double)"
discard printf("C: %lf (double)\n", f64)