[][src]Struct signifix::binary::Signifix

pub struct Signifix { /* fields omitted */ }

Intermediate implementor type of this module's TryFrom and Display trait implementations. Former tries to convert a given number into this type by determining the appropriate binary prefix, the normalized significand, and the decimal mark position while latter uses this type's fields to format the number as a string of four significant figures inclusive the binary prefix symbol.

Interpreted formatting parameters are

  • + to prefix positive numbers with a plus sign,
  • fill, alignment, and width to pad or align numbers.

Methods

impl Signifix[src]

pub fn significand(&self) -> f64[src]

Signed significand normalized from ±1.000 over ±999.9 to ±1 023.

pub fn numerator(&self) -> i32[src]

Signed significand numerator from ±1 000 to ±9 999.

pub fn denominator(&self) -> i32[src]

Significand denominator of either 1, 10, 100, or 1 000.

pub fn exponent(&self) -> usize[src]

Exponent of significand denominator of either 0, 1, 2, or 3.

pub fn integer(&self) -> i32[src]

Signed integer part of significand from ±1 to ±1 023.

pub fn fractional(&self) -> i32[src]

Fractional part of significand from 0 to 999.

pub fn parts(&self) -> (i32, i32)[src]

Signed integer and fractional part at once, in given order.

pub fn prefix(&self) -> usize[src]

Binary prefix as NAMES, SYMBOLS, and FACTORS array index from 0 to 8.

pub fn symbol(&self) -> Option<&str>[src]

Symbol of binary prefix from Some("Ki") to Some("Yi"), or None.

pub fn factor(&self) -> f64[src]

Factor of binary prefix from 1 024 ^ 1 to 1 024 ^ 8, or 1 024 ^ 0.

pub fn fmt(
    &self,
    f: &mut Formatter,
    decimal_mark: &str,
    grouping_sep: &str
) -> Result
[src]

Format trait implementation allowing explicit localization.

Until there is a recommended and possibly implicit localization system for Rust, explicit localization can be achieved by wrapping the Signifix type into a locale-sensitive newtype which implements the Display trait via this method. Used by this type's Display trait implementation with a decimal point as decimal_mark and a whitespace as grouping_sep. Both the decimal_mark and grouping_sep must be of a single character.

Trait Implementations

impl Clone for Signifix[src]

impl Copy for Signifix[src]

impl Debug for Signifix[src]

impl Display for Signifix[src]

impl Eq for Signifix[src]

impl Ord for Signifix[src]

impl PartialEq<Signifix> for Signifix[src]

impl PartialOrd<Signifix> for Signifix[src]

impl StructuralEq for Signifix[src]

impl StructuralPartialEq for Signifix[src]

impl TryFrom<f32> for Signifix[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<f64> for Signifix[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<i128> for Signifix[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<i16> for Signifix[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<i32> for Signifix[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<i64> for Signifix[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<i8> for Signifix[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<isize> for Signifix[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<u128> for Signifix[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<u16> for Signifix[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<u32> for Signifix[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<u64> for Signifix[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<u8> for Signifix[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<usize> for Signifix[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.