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

Fraction ceil and floor round negative fraction "the wrong way" #81

Closed
morri2 opened this issue Feb 19, 2023 · 1 comment · Fixed by #82
Closed

Fraction ceil and floor round negative fraction "the wrong way" #81

morri2 opened this issue Feb 19, 2023 · 1 comment · Fixed by #82

Comments

@morri2
Copy link
Contributor

morri2 commented Feb 19, 2023

Fraction::floor rounds negative Fractions upwards (towards zero), and Fraction::ceil rounds negative fractions towards negative infinity. Since the docs says that floor should "Returns the largest integer less than or equal to the value" I'm assuming this is unintentional

let f = Fraction::new_neg(1u8, 2u8);
println!("{} {}", f.floor(), f.ceil());

This example prints -0 -1 when the output should be -1 -0

@dnsl48
Copy link
Owner

dnsl48 commented Feb 24, 2023

The fix was released with 0.13.1.
Thanks again for the contribution!

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

Successfully merging a pull request may close this issue.

2 participants