packages

units::unit::prefix

On this page

SI prefixes, quecto (1e-30) to quetta (1e30).

Structs

PrefixSource

pub struct Prefix

An SI prefix: its symbol, name and power of ten.

nabi
use units::unit::prefix::Prefix;

let k = Prefix::find("k") ?? panic("k");
assert(k.name == "kilo" && k.power == 3);
  • pub symbol: str§

    Source

    The symbol ("k", "µ").

  • pub name: str§

    Source

    The name ("kilo").

  • pub power: i32§

    Source

    The power of ten (3).

  • pub fn all() -> List<Prefix>§

    Source

    Every prefix, the two-letter da first.

    nabi
    use units::unit::prefix::Prefix;
    
    assert(Prefix::all().len() == 24);
    
  • pub fn find(text: str) -> Prefix | none§

    Source

    The prefix with symbol or name text. The micro sign µ (U+00B5), the Greek μ (U+03BC) and ASCII u all give micro.

    nabi
    use units::unit::prefix::Prefix;
    
    assert((Prefix::find("μ") ?? panic("mu")).power == -6);
    assert((Prefix::find("mega") ?? panic("mega")).symbol == "M");
    
  • pub fn factor(self) -> f64§

    Source

    10^power, the double nearest it for every prefix.

    nabi
    use units::unit::prefix::Prefix;
    
    assert((Prefix::find("n") ?? panic("n")).factor() == 1e-9);