Skip to content
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

Negative zeros #435

Open
krlmlr opened this issue Feb 3, 2024 · 2 comments
Open

Negative zeros #435

krlmlr opened this issue Feb 3, 2024 · 2 comments

Comments

@krlmlr
Copy link
Contributor

krlmlr commented Feb 3, 2024

Are you expecting this? It's platform-specific, this is for the M1, Linux is different IIRC.

jsonlite::toJSON(-0x0p+0)
#> [-0]
-0x0p+0 == 0
#> [1] TRUE

Created on 2024-02-03 with reprex v2.1.0

@jeroen
Copy link
Owner

jeroen commented Feb 3, 2024

I guess technically this is not incorrect? It seems to retain the sign, even when R's print() does not:

> jsonlite::toJSON(-0)
## [-0]
> jsonlite::toJSON(0)
## [0]

@krlmlr
Copy link
Contributor Author

krlmlr commented Feb 4, 2024

Sure, but is it consistent across platforms? Might be worth adding a test.

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

No branches or pull requests

2 participants