-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.0 / abs(-0.0)
returns -inf instead of inf
#16494
Labels
Comments
proc abs*(x: float64): float64 {.noSideEffect, inline.} =
if x < 0.0: -x
elif x == 0.0: 0.0
else: x
proc abs*(x: float32): float32 {.noSideEffect, inline.} =
if x < 0.0: -x
elif x == 0.0: 0.0
else: x |
ringabout
added a commit
to ringabout/Nim
that referenced
this issue
Dec 30, 2020
mildred
pushed a commit
to mildred/Nim
that referenced
this issue
Jan 11, 2021
* fix nim-lang#16494 * fix * fix * fix * fix * fix * fix performance * add comments * improve performance * Update lib/system.nim Co-authored-by: Timothee Cour <[email protected]> * Update lib/system.nim Co-authored-by: Timothee Cour <[email protected]> * Update tests/stdlib/tmath_misc.nim Co-authored-by: Timothee Cour <[email protected]> * Update tests/stdlib/tmath_misc.nim Co-authored-by: Timothee Cour <[email protected]> Co-authored-by: Timothee Cour <[email protected]>
ardek66
pushed a commit
to ardek66/Nim
that referenced
this issue
Mar 26, 2021
* fix nim-lang#16494 * fix * fix * fix * fix * fix * fix performance * add comments * improve performance * Update lib/system.nim Co-authored-by: Timothee Cour <[email protected]> * Update lib/system.nim Co-authored-by: Timothee Cour <[email protected]> * Update tests/stdlib/tmath_misc.nim Co-authored-by: Timothee Cour <[email protected]> * Update tests/stdlib/tmath_misc.nim Co-authored-by: Timothee Cour <[email protected]> Co-authored-by: Timothee Cour <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1.0 / abs(-0.0)
returns -inf instead of infExample1: -0.0
Current Output
fails
Expected Output
works
Example 2: same issue with nans
Possible Solution
for implementation of
abs(SomeFloat)
, use importc fabs and fabsf in RT + VM (via vmops), with a fallback for js as usual; the fallback for js can use the same logic as for copySign(see #16406)Additional Information
devel 1.5.1 6d442a4
The text was updated successfully, but these errors were encountered: