Enum si_scale::base::Base [−][src]
pub enum Base {
B1000,
B1024,
}Expand description
Represents the base for units Prefix.
Variants
The most common base, where 1 k means 1000, 1 M means 1000^2, …
A very common base for bibytes, where 1 kiB means 1024, 1 MiB means
1024 * 1024, …
Implementations
Using floor(), returns the closest integer exponent to represent the
provided value x in the self Base.
The returned integer exponent is a multiple of 3 in order to match the prefixes’ exponents.
Example
use si_scale::base::Base;
let x: f32 = 5.4e4;
let actual = Base::B1000.integral_exponent_for(x);
assert_eq!(actual, 3); // 1e3
let x: f64 = -5.4e-4;
let actual = Base::B1000.integral_exponent_for(x);
assert_eq!(actual, -6); // 1e-6