Skip to content

[treeplayer] Fix precision loss in TTree::Scan for 64-bit integers#22600

Open
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:issue-7844
Open

[treeplayer] Fix precision loss in TTree::Scan for 64-bit integers#22600
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:issue-7844

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

The "lld" column format passed without an embedded size (e.g. via "colsize=N col=lld") was not recognized as a "long long" modifier in TTreeFormula::PrintValue, so 64-bit integer branches (e.g. ULong64_t) were evaluated as double and rounded above 2^53.

This commit fixes a off-by-one problem in the length-modifier detection to address the issue, adding also a regression test.

Closes #7844.

🤖 Done with the help of Claude Code (Claude Opus 4.8)

@github-actions

Copy link
Copy Markdown

Test Results

    22 files      22 suites   3d 18h 31m 58s ⏱️
 3 861 tests  3 861 ✅ 0 💤 0 ❌
77 191 runs  77 191 ✅ 0 💤 0 ❌

Results for commit c281308.

@jblomer jblomer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment thread tree/treeplayer/test/regressions.cxx Outdated
// The "long long" Scan/Draw column format is evaluated through `long double`
// (see TTreeFormula::PrintValue), so exact 64-bit integer output is only
// possible where `long double` has more mantissa bits than `double`. That is
// the case on x86-64 (80-bit, 64-bit mantissa) but not, e.g., on macOS ARM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we conversely test that the problem persists on macOS?

Perhaps (for a future PR), can we try to avoid floating point conversion at all when printing integers? For this we may want to leave the issue open.

Comment thread tree/treeplayer/test/regressions.cxx Outdated
Comment thread tree/treeplayer/test/regressions.cxx Outdated
Comment thread tree/treeplayer/test/regressions.cxx Outdated
} redirectFile{"tree_7844_regression_redirect.txt"};
treePlayer->SetScanRedirect(true);
treePlayer->SetScanFileName(redirectFile.fPath);
// The "lld" format without an embedded size (the size is given

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be an example for a format with an embedded size? Should we test this, too?

The `"lld"` column format passed without an embedded size (e.g. via
`"colsize=N col=lld"`) was not recognized as a `"long long"` modifier in
**TTreeFormula::PrintValue**, so 64-bit integer branches (e.g.
`ULong64_t`) were evaluated as double and rounded above 2^53.

This commit fixes a off-by-one problem in the length-modifier detection
to address the issue, adding also a regression test.

Closes root-project#7844.

🤖 Done with the help of [Claude Code](https://claude.com/claude-code) (Claude Opus 4.8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TTree::Scan() (and TTree::Draw()) issues with ULong64_t

3 participants