pub struct Ratio { /* private fields */ }Implementations§
Source§impl Ratio
impl Ratio
pub const OVERFLOW: i64 = i64::MAX
pub const UNDERFLOW: i64 = i64::MIN
pub fn new(numerator: u32, denominator: u32) -> Self
pub fn numerator(&self) -> u32
pub fn denominator(&self) -> u32
pub fn invertible(&self) -> bool
pub fn inverse(&self) -> Self
Sourcepub fn reduce_u32(numerator: &mut u32, denominator: &mut u32)
pub fn reduce_u32(numerator: &mut u32, denominator: &mut u32)
Reduces the ratio of numerator/denominator in-place (32-bit).
Sourcepub fn reduce_u64(numerator: &mut u64, denominator: &mut u64)
pub fn reduce_u64(numerator: &mut u64, denominator: &mut u64)
Reduces the ratio of numerator/denominator in-place (64-bit).
Sourcepub fn product_raw(
a_numerator: u32,
a_denominator: u32,
b_numerator: u32,
b_denominator: u32,
exact: Exact,
) -> (u32, u32)
pub fn product_raw( a_numerator: u32, a_denominator: u32, b_numerator: u32, b_denominator: u32, exact: Exact, ) -> (u32, u32)
Produces the product of two ratios.
If exact is Exact::Yes, this panics on loss of precision.
If exact is Exact::No, it attempts to find the best 32-bit approximation.
pub fn product(a: Ratio, b: Ratio, exact: Exact) -> Ratio
Trait Implementations§
impl Copy for Ratio
impl Eq for Ratio
impl StructuralPartialEq for Ratio
Auto Trait Implementations§
impl Freeze for Ratio
impl RefUnwindSafe for Ratio
impl Send for Ratio
impl Sync for Ratio
impl Unpin for Ratio
impl UnsafeUnpin for Ratio
impl UnwindSafe for Ratio
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more