Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print an even more meaningful message if WithinULP fails #1760

Closed
cschwan opened this issue Sep 25, 2019 · 2 comments
Closed

Print an even more meaningful message if WithinULP fails #1760

cschwan opened this issue Sep 25, 2019 · 2 comments

Comments

@cschwan
Copy link

cschwan commented Sep 25, 2019

Thank you very much for implementing #1581; this feature request is a follow up to it.

The problem that I still have is best illustrated using an example:

../tests/regression_test_lusifer_psg_wz_scattering.cpp:65245: FAILED:
  CHECK_THAT( d.at(j), Catch::WithinULP(densities.at(channel).at(j), 8) )
with expansion:                                                          
  0.0 is within 8 ULPs of 0.0 ([0.00000000000000019, 0.00000000000000019])

which obviously is still not very meaningful, because my numbers are very small, and therefore I still don't see the relevant digits that differ.

Since it can happen in general, I think one should always print the numbers in scientific format instead (or check it the number is in the interval [0.1, 10), print it with the fixed format, else print it scientifically, but that's probably too complicated).

Note that if you decide to print floating point numbers in the scientific format, you should set the precision to max_digits - 1, where the -1 comes from the fact that the precision field changes its meaning to 'digits after the comma', see my question on stackoverflow, for example.

@cschwan
Copy link
Author

cschwan commented Oct 3, 2019

To clarify: I suggest to show the numbers of the interval in scientific format.

As for the checked numbers themselves I am still a bit disappointed that they apparently can't be printed in the scientific format; would it be possible to globally change the behaviour of the printer (a desparate measure, but I'd be fine doing that in my own tests)?

@horenmar
Copy link
Member

You could try modifying the precision settings for floating point stringification to change how the checked number is displayed.

As for the interval, I'll play with different options for a bit before deciding what to do there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants