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

f32 and f64 support #1

Open
tnballo opened this issue Jun 27, 2021 · 0 comments
Open

f32 and f64 support #1

tnballo opened this issue Jun 27, 2021 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@tnballo
Copy link
Owner

tnballo commented Jun 27, 2021

Would be nice to add a small_float macro, rounding out (pun intended) numeric primitive support in this library. Unfortunately, determining when a lossless cast from an f64 constant to an f32 equivalent can be done is non-trivial. Due to the specifics of IEEE 754-2008, it’s not as simple as checking (($val as f32) as f64) == ($val as f64).

Maybe understanding how std::num::flt2dec works in supporting Debug for floats might provide some insight. If precision is not explicitly specified when printing, flt2dec helps determine the smallest significant precision (not reflected with an == comparison). But I’m not sure this methodology is 1) actually the desired solution here or 2) possible to implement in a macro_rules macro.

@tnballo tnballo added the help wanted Extra attention is needed label Jun 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant