pub type Ratio<U, V> = Quantity<Dimension, U, V>;
Expand description
Implementations§
source§impl<U, V> Ratio<U, V>where
U: Units<V> + ?Sized,
V: Num + Conversion<V>,
impl<U, V> Ratio<U, V>where U: Units<V> + ?Sized, V: Num + Conversion<V>,
sourcepub fn new<N>(v: V) -> Selfwhere
N: Unit + Conversion<V, T = V::T>,
pub fn new<N>(v: V) -> Selfwhere N: Unit + Conversion<V, T = V::T>,
sourcepub fn get<N>(&self) -> Vwhere
N: Unit + Conversion<V, T = V::T>,
pub fn get<N>(&self) -> Vwhere N: Unit + Conversion<V, T = V::T>,
sourcepub fn floor<N>(self) -> Selfwhere
V: Float,
N: Unit + Conversion<V, T = V::T>,
pub fn floor<N>(self) -> Selfwhere V: Float, N: Unit + Conversion<V, T = V::T>,
Returns the largest integer less than or equal to a number in the given measurement unit.
Generic Parameters
N
: Unit.
sourcepub fn ceil<N>(self) -> Selfwhere
V: Float,
N: Unit + Conversion<V, T = V::T>,
pub fn ceil<N>(self) -> Selfwhere V: Float, N: Unit + Conversion<V, T = V::T>,
Returns the smallest integer less than or equal to a number in the given measurement unit.
Generic Parameters
N
: Unit.
sourcepub fn round<N>(self) -> Selfwhere
V: Float,
N: Unit + Conversion<V, T = V::T>,
pub fn round<N>(self) -> Selfwhere V: Float, N: Unit + Conversion<V, T = V::T>,
Returns the nearest integer to a number in the in given measurement unit. Round half-way cases away from 0.0.
Generic Parameters
N
: Unit.
sourcepub fn format_args<N>(unit: N, style: DisplayStyle) -> Arguments<Dimension, N>where
N: Unit,
pub fn format_args<N>(unit: N, style: DisplayStyle) -> Arguments<Dimension, N>where N: Unit,
Creates a struct that can be used to format a compatible quantity for display.
Notes
The return value of this method cannot be used to print directly, but is instead used to format quantities and can be reused; see Arguments::with and the examples below.
If you do not need to format multiple quantities, consider using
into_format_args
instead.
Examples
let t1 = Time::new::<femtosecond>(1.0_E-1);
let t2 = Time::new::<picosecond>(1.0_E-1);
let a = Time::format_args(femtosecond, Description);
assert_eq!("0.1 femtoseconds", format!("{}", a.with(t1)));
assert_eq!("100 femtoseconds", format!("{}", a.with(t2)));
Generic Parameters
N
: Unit.
sourcepub fn into_format_args<N>(
self,
unit: N,
style: DisplayStyle
) -> QuantityArguments<Dimension, U, V, N>where
N: Unit,
pub fn into_format_args<N>( self, unit: N, style: DisplayStyle ) -> QuantityArguments<Dimension, U, V, N>where N: Unit,
Creates a struct that formats self
for display.
Notes
Unlike format_args
, the return value of this method can be
used directly for display. It will format the value of self
for the quantity on
which it is called and nothing else.
If you wish to reuse the return value to format multiple quantities, use
format_args
instead.
Examples
let t = Time::new::<picosecond>(1.0_E-1);
let a = t.into_format_args(femtosecond, Description);
assert_eq!("100 femtoseconds", format!("{}", a));
Generic Parameters
N
: Unit.
source§impl<U, V> Ratio<U, V>where
U: Units<V> + ?Sized,
V: Float + Conversion<V>,
radian: Conversion<V, T = V::T>,
ratio: Conversion<V, T = V::T>,
impl<U, V> Ratio<U, V>where U: Units<V> + ?Sized, V: Float + Conversion<V>, radian: Conversion<V, T = V::T>, ratio: Conversion<V, T = V::T>,
Implementation of various stdlib functions.
sourcepub fn acosh(self) -> Angle<U, V>
pub fn acosh(self) -> Angle<U, V>
Computes the value of the inverse hyperbolic cosine of the ratio.
sourcepub fn asinh(self) -> Angle<U, V>
pub fn asinh(self) -> Angle<U, V>
Computes the value of the inverse hyperbolic sine of the ratio.
sourcepub fn atanh(self) -> Angle<U, V>
pub fn atanh(self) -> Angle<U, V>
Computes the value of the inverse hyperbolic tangent of the ratio.
sourcepub fn log(self, base: V) -> Ratio<U, V>
pub fn log(self, base: V) -> Ratio<U, V>
Returns the logarithm of the number with respect to an arbitrary base.
The result might not be correctly rounded owing to implementation details; self.log2() can produce more accurate results for base 2, and self.log10() can produce more accurate results for base 10.