Commit e0e9ecb
committed
[treeplayer] Evaluate the "long" Scan format through long double
TTree::Scan prints each column with TTreeFormula::PrintValue, which
evaluates it in a floating-point accumulator. The "long" integer format
("ld"/"lu") used a double, whose 53-bit mantissa rounds any 64-bit
integer above 2^53, whereas the "long long" format ("lld"/"llu") already
used a long double. Promote "ld"/"lu" to long double as well, so that on
platforms where long double is wide enough -- e.g. x86-64, with a 64-bit
mantissa -- the full 64-bit value prints exactly, consistently with the
"long long" format.
This deliberately does NOT switch the evaluation to a 64-bit *integer*
accumulator, even though that would represent every value exactly.
TTreeFormula evaluates every column through a single numeric accumulator
whose type defines the arithmetic, and that arithmetic has always been
floating point. Carrying integers instead would silently change
long-standing, effectively frozen semantics:
- "x/2" would become integer division instead of floating division;
- literal constants would be truncated ("x*0.5" -> "x*0");
- division and modulo of unsigned values above 2^63 would differ,
because the evaluation is signed.
No accumulator type is simultaneously exact for every 64-bit integer and
faithful to the existing floating-point arithmetic; the two goals are
mutually exclusive for exactly the values at stake. Widening the float
keeps the arithmetic bit-for-bit identical while extending the range of
integers that are printed exactly.
🤖 Done with the help of [Claude Code](https://claude.com/claude-code) (Claude Opus 4.8)1 parent a622764 commit e0e9ecb
2 files changed
Lines changed: 12 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5072 | 5072 | | |
5073 | 5073 | | |
5074 | 5074 | | |
5075 | | - | |
| 5075 | + | |
5076 | 5076 | | |
5077 | 5077 | | |
5078 | 5078 | | |
| |||
5086 | 5086 | | |
5087 | 5087 | | |
5088 | 5088 | | |
5089 | | - | |
| 5089 | + | |
5090 | 5090 | | |
5091 | 5091 | | |
5092 | 5092 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
652 | 652 | | |
653 | 653 | | |
654 | 654 | | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
661 | 663 | | |
662 | 664 | | |
| 665 | + | |
| 666 | + | |
663 | 667 | | |
0 commit comments