anilmaurya / fast_jsonparser

Fastest Json parser for Ruby, wrapper for simdjson
MIT License
307 stars 10 forks source link

Parser is converting some numeric values incorrectly #17

Open justjoehere opened 4 years ago

justjoehere commented 4 years ago

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

anilmaurya commented 4 years ago

Hi @justjoehere

Can you confirm this issue on 0.5.0 version ?

justjoehere commented 4 years ago

Still occurs in 0.5.0.

anilmaurya commented 4 years ago

Hi @justjoehere

I added test case to reproduce this issue, https://github.com/anilmaurya/fast_jsonparser/commit/96ff5c513bb8d11ee9d2e593cfb2624a8ff9b9d6

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

ahorek commented 1 year ago

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