Type Definition quantity::QuantityScalar [−][src]
type QuantityScalar<U> = Quantity<f64, U>;
Implementations
Calculate the integer power of self.
Example
let x = 5.0 * METER; assert_relative_eq!(x.powi(2), &(25.0 * METER * METER));
Try to calculate the square root of self.
Example
let x = 25.0 * METER * METER; assert_relative_eq!(x.sqrt()?, &(5.0 * METER)); assert!(METER.sqrt().is_err());
Try to calculate the cubic root of self.
Example
let x = 125.0 * METER * METER * METER; assert_relative_eq!(x.cbrt()?, &(5.0 * METER)); assert!(METER.cbrt().is_err());
Try to calculate the integer root of self.
Example
let x = 625.0 * METER * METER * METER * METER; assert_relative_eq!(x.root(4)?, &(5.0 * METER)); assert!(METER.root(4).is_err());
Return the maximum of self
and other
if they have the same unit.
Example
let p1 = 110.0 * KILO * PASCAL; let p2 = BAR; assert_relative_eq!(p1.max(p2)?, &p1); assert!(BAR.max(KELVIN).is_err());
Return the minimum of self
and other
if they have the same unit.
Example
let p1 = 110.0 * KILO * PASCAL; let p2 = BAR; assert_relative_eq!(p1.min(p2)?, &p2); assert!(BAR.min(KELVIN).is_err());
Return the absolute value of self
.
Example
let t = -50.0 * KELVIN; assert_relative_eq!(t.abs(), &(50.0 * KELVIN));
Returns a number that represents the sign of self
.
1.0
if the number is positive,+0.0
orINFINITY
-1.0
if the number is negative,-0.0
orNEG_INFINITY
NAN
if the number isNAN
Returns true
if self
has a positive sign, including +0.0
, NaN
s with
positive sign bit and positive infinity.
Returns true
if self
has a negative sign, including -0.0
, NaN
s with
negative sign bit and negative infinity.