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:
@@ -142,6 +142,11 @@ $ h5rs diff -d 0.001 a.h5 b.h5 # |a - b| > 0.001 is a difference
|
||||
$ h5rs diff -p 0.01 a.h5 b.h5 # |a - b| / |a| > 1% is a difference
|
||||
```
|
||||
|
||||
Integers are compared in integer arithmetic, with or without a tolerance, so
|
||||
64-bit values beyond 2^53 lose no precision (`-d 0` tells 2^60 from
|
||||
2^60 + 1). A relative tolerance below the f64 epsilon (2.2e-16) compares
|
||||
exactly, as h5diff's does.
|
||||
|
||||
Exit status: 0 no differences, 1 differences, 2 error — the same as h5diff's
|
||||
on the cases `diff_exit_codes_match_h5diff` runs. Compared: which objects
|
||||
exist, their kinds, datatypes and shapes, attribute sets and values, dataset
|
||||
|
||||
Reference in New Issue
Block a user