Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions jsroot/types/fundamental/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@
* [`real`](real): `Real{16,32,64}`, `SplitReal{32,64}`
* [`real32trunc`](real32trunc): `Real32Trunc`
* [`real32quant`](real32quant): `Real32Quant`

Note:
- the columns of `real32quant` are more precise in JSROOT, since JavaScript natively supports double-precision floats
11 changes: 10 additions & 1 deletion jsroot/types/fundamental/real32quant/read.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import { read, floatToHex } from "../../../jsroot_reader.mjs";

function formatFloat(num, { field }) {
Comment thread
hahnjo marked this conversation as resolved.
// round num to single-precision float to match the required field precision
if (field.startsWith("Float")) {
num = Math.fround(num);
}

return floatToHex(num);
}

const fields = [
"FloatReal32Quant1",
"FloatReal32Quant8",
Expand All @@ -12,4 +21,4 @@ const fields = [
const [input = "types.fundamental.real32quant.root", output = "types.fundamental.real32quant.json"] =
process.argv.slice(2);

read(input, output, fields, floatToHex);
read(input, output, fields, formatFloat);