-
Notifications
You must be signed in to change notification settings - Fork 56
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
Convert Ratio of integers to f64 #52
Conversation
Try running It seems like your code depends on std. This crate supports nostd. If you can make it work with FloatCore, that would be great, If you want CI to work, try throwing in some |
Ok, I'll make sure that passes. Given that this code needs |
You need |
Ok that makes sense, I'll add both feature flags. I think most of what I use is actually in core, except for |
@maxbla I agree with your comments above, I've pushed a new revision which handles both 16-bit architectures and arbitrarily wide |
0904132
to
7837c55
Compare
I've moved a bigint-based unit test to the doctests to show the possibility of using BigInts. Does anyone have time to take another look at the review? |
Sorry, yes, I mean to give this a deeper review, but haven't gotten to it yet. It just came up in #54 too -- is there a reason you added a new method instead of implementing |
No particular reason—it's more work to implement all of I do have a small reason for not doing the full |
FWIW, the default
The design of public API is important though, because we'll be stuck with it. I think
Sure, we can and should enhance docs -- the current semantics of the primitive implementations are that they only return |
Ok, that makes sense. I'll put out a new version that implements
ToPrimitive.
|
916e0b5
to
89ef262
Compare
I've pushed a version with |
If the original author doesn't makes the suggested changes, I'd be happy to drag this PR to the finish line. |
@maxbla that's fine with me, just keep the original commit for authorship and then add your own. It needs to be rebased too. |
Hey sorry, I think I missed the review notification. @maxbla if you have time feel free to take over, otherwise I can take a look this weekend. |
I would be happy for you to make the suggested changes. I only offered because it looked like you were done. |
Yeah if you have time to get started before this weekend go for it! |
Performs the division with integer arithmetic, and rounds before performing an exact cast to float. This avoids any issues with rounding.
These can be provided even when BigInts are unavailable.
I've implemented the suggested changes:
|
Provides an alternative implementation of ToPrimitive for 64-bit integer types when BigInt is not available.
Looks great, thanks! bors r+ |
Build succeeded |
Performs the division with integer arithmetic, and rounds
before performing an exact cast to float. This avoids any
issues with rounding.
General method referenced from https://stackoverflow.com/questions/33623875/converting-an-arbitrary-precision-rational-number-ocaml-zarith-to-an-approxim.
Partially fixes #4 (no support for
f32
conversion currently).