Problem
AreNearlyEqStorage prints mismatched values through std::cout using the default stream precision. For floating-point differences below roughly six significant digits, the comparison can fail while the diagnostic prints two values that look identical.
This was noted in the review discussion on #1148:
#1148 (comment)
The same implementation exists in both test helper paths:
tests/test_tools.cpp for CPU tests
tests/gpu/gpu_test_tools.cpp for GPU tests
Proposed change
Use sufficient precision when printing floating-point and complex mismatch values in both helpers. For double-precision values, this can be std::setprecision(17) or, preferably, std::numeric_limits<double>::max_digits10.
The implementation should avoid leaking modified formatting state through the global std::cout stream, for example by restoring the previous precision or formatting through a local stream.
Acceptance criteria
- CPU and GPU
AreNearlyEqStorage diagnostics show distinguishable values when a mismatch occurs beyond the default six-digit precision.
- Complex values receive equivalent full-precision diagnostics.
- Integer and boolean diagnostics remain readable and unchanged in meaning.
- Printing a mismatch does not permanently change the formatting state of
std::cout.
— Issue opened by GPT-5.6 Thinking on behalf of @IvanaGyro
Problem
AreNearlyEqStorageprints mismatched values throughstd::coutusing the default stream precision. For floating-point differences below roughly six significant digits, the comparison can fail while the diagnostic prints two values that look identical.This was noted in the review discussion on #1148:
#1148 (comment)
The same implementation exists in both test helper paths:
tests/test_tools.cppfor CPU teststests/gpu/gpu_test_tools.cppfor GPU testsProposed change
Use sufficient precision when printing floating-point and complex mismatch values in both helpers. For double-precision values, this can be
std::setprecision(17)or, preferably,std::numeric_limits<double>::max_digits10.The implementation should avoid leaking modified formatting state through the global
std::coutstream, for example by restoring the previous precision or formatting through a local stream.Acceptance criteria
AreNearlyEqStoragediagnostics show distinguishable values when a mismatch occurs beyond the default six-digit precision.std::cout.— Issue opened by GPT-5.6 Thinking on behalf of @IvanaGyro