Expand description
Represents a float value using its mantissa and unit Prefix in a base.
With base = 1000, 1k = 1000, 1M = 1_000_000, 1m = 0.001, 1µ = 0.000_001, etc.
| min (incl.) | max (excl.) | magnitude | prefix |
|---|---|---|---|
| .. | .. | -24 | Prefix::Yocto |
| .. | .. | -21 | Prefix::Zepto |
| .. | .. | -18 | Prefix::Atto |
| .. | .. | -15 | Prefix::Femto |
| .. | .. | -12 | Prefix::Pico |
| .. | .. | -9 | Prefix::Nano |
| 0.000_001 | 0.001 | -6 | Prefix::Micro |
| 0.001 | 1 | -3 | Prefix::Milli |
| 1 | 1_000 | 0 | Prefix::Unit |
| 1000 | 1_000_000 | 3 | Prefix::Kilo |
| 1_000_000 | 1_000_000_000 | 6 | Prefix::Mega |
| .. | .. | 9 | Prefix::Giga |
| .. | .. | 12 | Prefix::Tera |
| .. | .. | 15 | Prefix::Peta |
| .. | .. | 18 | Prefix::Exa |
| .. | .. | 21 | Prefix::Zetta |
| .. | .. | 24 | Prefix::Yotta |
The base is usually 1000, but can also be 1024 (bibytes).
With base = 1024, 1ki = 1024, 1Mi = 1024 * 1024, etc.
§Example
use std::convert::From;
use si_scale::{base::Base, value::Value, prefix::Prefix};
let actual = Value::from(0.123);
let expected = Value {
mantissa: 123f64,
prefix: Prefix::Milli,
base: Base::B1000,
};
assert_eq!(actual, expected);Structs§
- Value
- Defines the representation of the value.