dnsl48 / fraction

[Rust] Lossless fractions and decimals; drop-in float replacement
Apache License 2.0
83 stars 25 forks source link

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

Closed morri2 closed 1 year ago

morri2 commented 1 year ago

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 commented 1 year ago

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