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

Parser is converting some numeric values incorrectly #17

Open
justjoehere opened this issue Aug 10, 2020 · 4 comments · May be fixed by #27
Open

Parser is converting some numeric values incorrectly #17

justjoehere opened this issue Aug 10, 2020 · 4 comments · May be fixed by #27

Comments

@justjoehere
Copy link

justjoehere commented Aug 10, 2020

Executing the following code
FastJsonparser.parse("[{ \"duration\": 7386425359 }]")

Results in
{ :duration => -1203509233 }

This parsing is resulting in a change in values
7386425359 is being converted to -1203509233

It's like there's a weird conversion from an unsigned to a signed 33 bit conversion taking place. I used this tool to make that guess https://onlinetoolz.net/unsigned-signed#base=10&value=7386425359&bits=33

@justjoehere justjoehere changed the title Parser is converting Parser is converting some numeric values incorrectly Aug 10, 2020
anilmaurya pushed a commit that referenced this issue Aug 25, 2020
@anilmaurya
Copy link
Owner

Hi @justjoehere

Can you confirm this issue on 0.5.0 version ?

@justjoehere
Copy link
Author

Still occurs in 0.5.0.

@anilmaurya
Copy link
Owner

Hi @justjoehere

I added test case to reproduce this issue, 96ff5c5

But test cases is passing.
Can you provide a failing test for this issue ?

@ahorek ahorek linked a pull request Jul 30, 2023 that will close this issue
@ahorek
Copy link

ahorek commented Jul 30, 2023

the test is actually failing on platforms where sizeof(long) != 32 like Windows.

# Running:

.......F..

Finished in 0.176423s, 56.6819 runs/s, 113.3638 assertions/s.

  1) Failure:
FastJsonparserTest#test_large_integer_parsing [c:/moje/gem/fast_jsonparser/test/fast_jsonparser_test.rb:83]:
Expected: -601754617
  Actual: 7386425359

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 a pull request may close this issue.

3 participants