Repository navigation
Fix reading of negative 64-bit integers - #422
Merged
Merged
Conversation
~ returns a signed int32, so negative Long64_t values whose low word is below 0x80000000 were read off by +2^32 (e.g. -2^32 came back as 0). Convert ~high and ~low back to unsigned with >>> 0 before combining.
Member
|
Thanks for the fix. Can you also provide test which one can add to CI. https://github.com/root-project/jsroot/blob/master/demo/node/rntuple_test.js And include this test to: https://github.com/root-project/jsroot/blob/master/.github/workflows/jsroot-ci.yml It would be grate if you can implement this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This Pull request:
fixes negative Long64_t values being read wrong. for some negative numbers jsroot shows a different value than root, e.g. -4294967296 shows up as 0.
repro tree:
t->Scan("v", "", "col=22lld")in root vs dumpingvin jsroot:Changes:
in
TBuffer.ntoi8()the negative branch uses~highand~lowdirectly.~gives back a signed int32, so when the low word is below 0x80000000~lowis negative and the result is off by +2^32. the bigint branch had the same problem. i convert both back to unsigned with>>> 0before combining them. values where the low word has the top bit set (like -1 and -4294967297) were already right, which is probably why nobody noticed.i checked
ntoi8()againstDataView.getBigInt64()for 0, ±1, -2, -2^31, -2^32, -2^32-1, -5e9, -(2^53-1), -2^53, INT64_MIN, 2^32, 2^53-1 and INT64_MAX. before 4 of them were wrong, now all 14 match. positive values andntou8()arent touched.Fixes:
jsroot now shows the same values as root for every Long64_t.