fix(tools): h5rs diff compares integers exactly under -d/-p

With a tolerance, integers were converted to f64 before comparing, so
int64/uint64 values above 2^53 that differ compared equal: -d 0 on 2^60
and 2^60 + 1 exited 0, where h5diff exits 1. Integer pairs are now
compared in i128 (the delta against floor(D), the relative quotient from
an exact difference), and the report prints the exact difference.

h5diff compares exactly when -p is below the f64 epsilon (2^60 and
2^60 + 1 differ at -p 1e-18, and nextafter(2, 0) and 2 at -p 1.5e-16);
h5rs now does the same.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
osobh
2026-09-26 01:16:09 -05:00
co-authored by Claude Opus 5.5
parent 699ee9c447
commit f325d111f3
5 changed files with 102 additions and 10 deletions
+4 -1
View File
@@ -131,7 +131,10 @@
- `h5rs diff [-r] [-q] [-d D] [-p R] A B [OBJ1 [OBJ2]]` compares objects,
kinds, datatypes, shapes, attributes, values and link targets; exit
status 0/1/2 as h5diff's. Every path is compared, including every name
of a hard-linked object and the members of a hard-linked group. Objects
of a hard-linked object and the members of a hard-linked group; with a
`-d`/`-p` tolerance, integers are compared exactly in integer
arithmetic (no loss above 2^53), and a `-p` below the f64 epsilon
compares exactly, as h5diff's. Objects
that cannot be compared count as a difference (h5diff exits 0 for them),
and NaN equals NaN.
- `h5rs check [--data] FILE` is a structural validator: it walks every