Skip to content

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

Merged
guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:issue-7844
Jun 15, 2026
Merged

[treeplayer] Fix precision loss in TTree::Scan for 64-bit integers#22600
guitargeek merged 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

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown

Test Results

    21 files      21 suites   3d 7h 17m 18s ⏱️
 3 863 tests  3 863 ✅ 0 💤 0 ❌
72 828 runs  72 828 ✅ 0 💤 0 ❌

Results for commit 570f2e1.

♻️ This comment has been updated with latest results.

@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
Comment thread tree/treeplayer/test/regressions.cxx
Comment thread tree/treeplayer/test/regressions.cxx Outdated
Comment thread tree/treeplayer/test/regressions.cxx Outdated
Comment thread tree/treeplayer/test/regressions.cxx Outdated

@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!

LGTM but I think @pcanal should take a look, too.
I think we should keep the issue open until all the platforms are fixed.

Comment thread tree/treeplayer/test/regressions.cxx Outdated
Comment thread tree/treeplayer/test/regressions.cxx Outdated
Comment thread tree/treeplayer/test/regressions.cxx Outdated
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)
@guitargeek

guitargeek commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks!

LGTM but I think @pcanal should take a look, too. I think we should keep the issue open until all the platforms are fixed.

Thanks for the review! I'm fine to keep the issue open even after merging this PR, but I think if the proper fix for all platforms will be much more than a few lines change we should also consider to just error out and declare this a "known limitation", as I also argued in this comment #22600 (comment). But let's see, maybe supporting long long printing of arbitrary values on all platforms by not going over long double won't be hard in a follow-up PR.

Comment on lines +605 to +608
if (std::numeric_limits<long double>::digits <= std::numeric_limits<double>::digits)
GTEST_SKIP() << "long double is not wider than double here; the 64-bit value "
"is genuinely unrepresentable and exactness cannot be checked";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should consider lifting this restriction by adding explicit support for unsigned long long inside TTreeFormula.

@pcanal pcanal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is a necessary change. Although the test skip may indicate need for further refinement.

@pcanal

pcanal commented Jun 15, 2026

Copy link
Copy Markdown
Member

But let's see, maybe supporting long long printing of arbitrary values on all platforms by not going over long double won't be hard in a follow-up PR.

As far as I know there should not be any issue with long long and only with unsigned long long.

we should also consider to just error out and declare this a "known limitation"

If we were to add this we would need to "only" print it if the value overflows (i.e. it works in most cases).

@guitargeek guitargeek merged commit 7cea10c into root-project:master Jun 15, 2026
32 of 33 checks passed
@guitargeek guitargeek deleted the issue-7844 branch June 15, 2026 18:19
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

4 participants