diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2021-01-11 04:39:38 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-11 11:39:38 +0100 |
commit | be6e8916faa51d227d51e1291d1f24751385b010 (patch) | |
tree | 4f4e7d5e843b3b850f5cfb4dfdd3030b73310976 /tests | |
parent | 5897ed9d3d5ca5f84423e87a70addc8c6764923e (diff) | |
download | Nim-be6e8916faa51d227d51e1291d1f24751385b010.tar.gz |
fix negative nan (#16628)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stdlib/tmath.nim | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/stdlib/tmath.nim b/tests/stdlib/tmath.nim index 62fdcd19f..edab62a66 100644 --- a/tests/stdlib/tmath.nim +++ b/tests/stdlib/tmath.nim @@ -319,6 +319,18 @@ template main = doAssert not Inf.isNaN doAssert isNaN(Inf - Inf) + block: # signbit + let x1 = NaN + let x2 = -NaN + let x3 = -x1 + + doAssert isNaN(x1) + doAssert isNaN(x2) + doAssert isNaN(x3) + doAssert not signbit(x1) + doAssert signbit(x2) + doAssert signbit(x3) + block: # copySign doAssert copySign(10.0, -1.0) == -10.0 doAssert copySign(-10.0, -1.0) == -10.0 @@ -385,8 +397,8 @@ template main = discard else: when not defined(js): - doAssert copySign(-1.0, -NaN) == 1.0 - doAssert copySign(10.0, -NaN) == 10.0 + doAssert copySign(-1.0, -NaN) == -1.0 + doAssert copySign(10.0, -NaN) == -10.0 doAssert copySign(1.0, copySign(NaN, -1.0)) == -1.0 # fails in VM block: |