-0 and 0 | Toph Tucker | Observable
•ojs
•ojs
•ojs
•ojs
•ojs
•ojs
•ojs
•ojs
•ojs
•ojs
•ojs
•ojs
•ojs
•ojs
Comments (2)
Jacob Rus
Jun 12, 2022
I routinely define the function: sign = x => Math.sign(x) || Math.sign(1/x); This is different than the mathematical signum function, but helps in cases where -0 and +0 should have different behavior.
Jun 12, 2022
If you want a cheaper binary result you can define something like: nonnegative = x => (x > 0) | (1/x > 0)
Reply
Add comment
Subscribe to notifications
Observable
Sign in
Toph Tucker
0
Reply
Add comment
Subscribe to notifications
0
-0 and 0 | Toph Tucker | Observable