Struct oxygen_quark::fraction::Fraction
source · Fields
numerator: i64
The numerator
denominator: i64
The denominator
Implementations
sourceimpl Fraction
impl Fraction
sourcepub fn new(numerator: i64) -> Fraction
pub fn new(numerator: i64) -> Fraction
Generates a new Fraction
It returns a Fraction
in its fully reduced form,
after calculating the greatest common divisor.
sourcepub fn new_denom(numerator: i64, denominator: i64) -> Fraction
pub fn new_denom(numerator: i64, denominator: i64) -> Fraction
Generates a new Fraction
It returns a Fraction
in its fully reduced form,
after calculating the greatest common divisor.
Panics
Panics if denominator
is zero (0).
sourcepub fn greatest_common_divisor(numerator: i64, denominator: i64) -> i64
pub fn greatest_common_divisor(numerator: i64, denominator: i64) -> i64
Returns the greatest common divisor, as an i64
.
Examples
let n1 = 50;
let n2 = 20;
// Prints out "10"
println!("{}", Fraction::greatest_common_divisor(n1, n2));
sourcepub fn reciprocal(self) -> Fraction
pub fn reciprocal(self) -> Fraction
Returns the reciprocal of the Fraction
it’s called on.
Just moves the denominator to the numerator position and vice versa.
Panics
Panics when being called on a Fraction
with numerator 0.
sourcepub fn cosine(self) -> Fraction
pub fn cosine(self) -> Fraction
Returns an approximated Fraction
of the cosine (cos) of the Fraction
sourcepub fn arc_cosine(self) -> Fraction
pub fn arc_cosine(self) -> Fraction
Returns an approximated Fraction
of the arc cosine (cos^-1) of the Fraction
sourcepub fn sine(self) -> Fraction
pub fn sine(self) -> Fraction
Returns an approximated Fraction
of the sine (sin) of the Fraction
sourcepub fn arc_sine(self) -> Fraction
pub fn arc_sine(self) -> Fraction
Returns an approximated Fraction
of the arc sine (sin^-1) of the Fraction
sourcepub fn tangent(self) -> Fraction
pub fn tangent(self) -> Fraction
Returns an approximated Fraction
of the tangent (tan) of the Fraction
sourcepub fn arc_tangent(self) -> Fraction
pub fn arc_tangent(self) -> Fraction
Returns an approximated Fraction
of the arc tangent (tan^-1) of the Fraction
Trait Implementations
sourceimpl AddAssign<Fraction> for Fraction
impl AddAssign<Fraction> for Fraction
sourcefn add_assign(&mut self, other: Fraction)
fn add_assign(&mut self, other: Fraction)
+=
operation. Read moresourceimpl DivAssign<Fraction> for Fraction
impl DivAssign<Fraction> for Fraction
sourcefn div_assign(&mut self, other: Fraction)
fn div_assign(&mut self, other: Fraction)
/=
operation. Read moresourceimpl MulAssign<Fraction> for Fraction
impl MulAssign<Fraction> for Fraction
sourcefn mul_assign(&mut self, other: Fraction)
fn mul_assign(&mut self, other: Fraction)
*=
operation. Read moresourceimpl Ord for Fraction
impl Ord for Fraction
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
sourceimpl PartialOrd<Fraction> for Fraction
impl PartialOrd<Fraction> for Fraction
sourcefn partial_cmp(&self, other: &Fraction) -> Option<Ordering>
fn partial_cmp(&self, other: &Fraction) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresourceimpl SubAssign<Fraction> for Fraction
impl SubAssign<Fraction> for Fraction
sourcefn sub_assign(&mut self, other: Fraction)
fn sub_assign(&mut self, other: Fraction)
-=
operation. Read more