-
Notifications
You must be signed in to change notification settings - Fork 468
ReScript force normalizing -0
to 0
#6736
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
Comments
Adding here some ChatGPT explanation Prompt: "Explain why JavaScript distinguishes ChatGPT answerJavaScript's distinction between This distinction is useful in certain mathematical computations, particularly those involving limits, derivatives, or integrals in calculus, where the direction of approach towards zero can affect the result. For example, in functions that compute the slope of a tangent or the rate of change, knowing the direction from which zero is approached (positive or negative) can be crucial. Potential Problems Arising from Normalizing
|
let a = -0; This is an int literal. IEEE 754 is the specification for floats. If you make it a float literal it will behave as you expect: let a = -0.; var a = -0; |
I see, yet again #6737 😅 |
It's subtle that this problem continues to occur when simply casting Int<->Float for interacting with JS bindings |
See my answer in #6737 (comment). It's really no more surprising than |
This comment was marked as duplicate.
This comment was marked as duplicate.
It seems to be the same topic with #6737, I'm closing this to merge discussions. I will move my last comment. |
produces
-0
is is an IEEE 754 standard, and JavaScript strictly follows it. This can cause problems in code that relies on this strict distinction, such asObject.is
The text was updated successfully, but these errors were encountered: