pub struct Ratio {
pub num: BigInt,
pub den: BigInt,
}Fields§
§num: BigInt§den: BigIntImplementations§
Source§impl Ratio
impl Ratio
pub fn new(num: BigInt, den: BigInt) -> Option<Self>
pub fn from_bigint(num: BigInt) -> Self
fn reduce(&mut self)
fn gcd_abs(a: &[u8], b: &[u8]) -> BigInt
Sourcepub fn new_or_zero(num: BigInt, den: BigInt) -> Self
pub fn new_or_zero(num: BigInt, den: BigInt) -> Self
new が失敗 (分母ゼロ) した場合に panic せず 0 を返すフォールバック付き生成。
分母非ゼロは呼び出し側の不変条件であり、通常は new がそのまま成功する。
pub fn add(&self, other: &Self) -> Self
pub fn sub(&self, other: &Self) -> Self
pub fn mul(&self, other: &Self) -> Self
pub fn div(&self, other: &Self) -> Option<Self>
pub fn to_string(&self) -> String
pub fn to_f64(&self) -> f64
pub fn from_f64(val: f64) -> Option<Self>
Trait Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.