Skip to content

Add rntuple_test32 to CI - #412

Merged
linev merged 2 commits into
devfrom
ci_rntuple2
Aug 3, 2026
Merged

Add rntuple_test32 to CI#412
linev merged 2 commits into
devfrom
ci_rntuple2

Conversation

@linev

@linev linev commented Aug 3, 2026

Copy link
Copy Markdown
Member

Adding 32bit types tests,
taken from #411

Thanks to @undefined-panda

@linev linev self-assigned this Aug 3, 2026
@linev
linev merged commit f7b5a3e into dev Aug 3, 2026
18 checks passed
@linev
linev deleted the ci_rntuple2 branch August 3, 2026 09:20
@undefined-panda

Copy link
Copy Markdown
Contributor

I discovered that you can fix the excessive precision problem for 32 bit floats with this:

export function floatToHex(num, { field }) {
  if (num === 0) return (Object.is(num, -0) ? "-" : "") + "0x0p+0";
  
  // convert num to Float32 for correct precision
  if (field.startsWith("Float")) {
    const tmp = new DataView(new ArrayBuffer(4));
    tmp.setFloat32(0, num, false);
    num = tmp.getFloat32(0, false);
  }

  const buf = new ArrayBuffer(8); // 8 Byte == 64 Bit
  const view = new DataView(buf);
  view.setFloat64(0, num, false);

However, for that it is required to know if num is meant to be a float or double, for example by the name of the field.

@linev

linev commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

You are free to create PR if you think that this improve testing

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