-
Notifications
You must be signed in to change notification settings - Fork 9
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
FBig and other dashu types should implement num
crate traits
#31
Comments
Thanks for the comments, support for Regarding My advice will be creating your own traits if you want to generalize over floats. Only put the methods you need in the traits. |
Besides, I would also like to point out that the macro |
Thank you for the information. |
Hi, does that mean they will implement traits in num_traits then? |
I won't implement num-trait::Float for thr FBig, since that trait is somewhat incompatible with arbitrary precision floats. |
Interesting! How come? (is it because of the copy bound?) |
I would like to close the issue due to the reason I explained in #31 (comment). The |
The native, correct way to handle new types of floating point numbers (and integers, for that matter) is by implementing the de-facto traits of that: https://crates.io/crates/num
For example, instead of using
fbig!(1)
, FBig should implementnum::cast::FromPrimitive
, where then this conversion can be done with something likeFBig::from_u64(1).unwrap()
.Also,
FBig
should implementnum::Float
.It would be really nice to have these implemented, so that the crate types can be used like other floating-point numbers and integers in rust. Having special, isolated work for everything just makes it harder to integrate dashu into projects. Currently all my code that works with Float trait cannot be ported to dashu, so I have to duplicate things just for dashu to work.
The text was updated successfully, but these errors were encountered: