Skip to content

fix: correctly detect negative zero when serializing floats to JS - #3217

Open
Abhinav kumar (abhiraz7) wants to merge 1 commit into
microsoft:mainfrom
abhiraz7:fix-negative-zero-serialization
Open

Abhinav kumar (abhiraz7) wants to merge 1 commit into
microsoft:mainfrom
abhiraz7:fix-negative-zero-serialization

Conversation

@abhiraz7

Copy link
Copy Markdown

Fixes #3186.

value == float("-0") is always true for any 0.0 in Python
since float
equality doesn't distinguish signed zero — > so every plain 0.0 passed to
evaluate() was incorrectly serialized to JS -0. This uses math.copysign
to check the actual sign instead, and adds a regression test mirroring
the issue's repro (Object.is(a, -0)).

0.0 == float('-0') is True in Python (float equality doesn'tdistinguish signed zero), so every 0.0 passed to evaluate() wasbeing tagged as -0 in the JS handshake. Use math.copysign to testthe actual sign bit instead.Fixes microsoft#3186
@abhiraz7

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 0.0 is serialized as -0 when passed to evaluate()

1 participant