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 float values in asserts in non-scientific format #21

Open
jtempest opened this issue Jan 22, 2022 · 0 comments
Open

Print float values in asserts in non-scientific format #21

jtempest opened this issue Jan 22, 2022 · 0 comments

Comments

@jtempest
Copy link
Owner

Rust 1.58 changed how floats output with {:?} are displayed. When they are larger or smaller than a specific threshold, then the output switches to scientific notation. This makes the assert_float_eq! output less helpful, as the non-scientific notation is much clearer for comparing values side by side:

    left: `1.0`,
   right: `1.0000002`,
abs_diff: `0.00000023841858`,

Compare with:

    left: `1.0`,
   right: `1.0000002`,
abs_diff: `2.3841858e-7`,

Unfortunately, there appears to be no way to disable this behaviour with a format specifier. It is plausible that a solution may involve wrapping numeric outputs from float_eq's traits to print in this format. This is a significant amount of work.

jtempest added a commit that referenced this issue Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant