Skip to content

[ntuple] Fix kReal32Quant decoding for 32-bit values - #411

Merged
linev merged 1 commit into
root-project:devfrom
undefined-panda:fix-kReal32Quant
Jul 29, 2026
Merged

[ntuple] Fix kReal32Quant decoding for 32-bit values#411
linev merged 1 commit into
root-project:devfrom
undefined-panda:fix-kReal32Quant

Conversation

@undefined-panda

Copy link
Copy Markdown
Contributor

Avoid 5-bit masking of JS shift counts, which made divisor 0 at nbits = 32.
Cast res to Uint32, s.t. bit 31 is not interpreted as sign bit.

Avoid 5-bit masking of JS shift counts, which made divisor 0 at nbits = 32.
Cast res to Uint32, s.t. bit 31 is not interpreted as sign bit.
@linev linev self-assigned this Jul 28, 2026
@linev
linev self-requested a review July 28, 2026 15:44
@linev
linev changed the base branch from master to dev July 28, 2026 15:52
@linev

linev commented Jul 28, 2026

Copy link
Copy Markdown
Member

Can you provide small test file with such corner cases - from this and previous PR.
And node.js macro which checks expected content.
Like in demo/node/rntuple_test.js

I want to include this macro in jsroot-ci.yml

@undefined-panda

Copy link
Copy Markdown
Contributor Author

real32quant.zip
This folder contains a .root and .mjs file from the RNTuple Validation Suite, aswell as the JSON files created by ROOT, JSROOT before the change and after. It can be seen, that (with my current floatToHex function) the JSROOT result is more precise than ROOT, since JS works with double while ROOT works with floats for quant. floats. I hope these files are self-explanatory, but if not, please let me know.

@linev
linev merged commit e0d2298 into root-project:dev Jul 29, 2026
18 checks passed
@linev

linev commented Jul 29, 2026

Copy link
Copy Markdown
Member

You are using #jsroot_reader module. I guess, it is some private module from you.

Can you adjust reader.mjs that it works without it and instead writing some JSON file compare read values with some predefined values. Something like code from rntuple_test,js:

   for (const field of fields) {
      try {
         const value = this.tgtobj[field],
               expected = expectedValues[field];

         if (!compare(expected, value, epsilonValues[field])) {
            console.error(`FAILURE: ${field} at entry ${entryIndex} expected ${JSON.stringify(expected)}, got ${JSON.stringify(value)}`);
            any_error = true;
         } else {
            const res = typeof value === 'bigint' ? value.toString() + 'n' : JSON.stringify(value);
            console.log(`OK: ${field} at entry ${entryIndex} = ${res}`);
         }
      } catch (err) {
         console.error(`ERROR: Failed to read ${field} at entry ${entryIndex}: ${err.message}`);
         any_error = true;
      }
   }

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.

2 participants