fn fmt(&self, form: &mut fmt::Formatter<'_>) -> fmt::Result {
        let tmp: String;
        let prec = match form.precision() {
            Some(prec) => min(prec, MAX_N_FRAC_DIGITS as usize),
            None => self.n_frac_digits as usize,
        };
        if self.n_frac_digits == 0 {
            if prec > 0 {
                tmp =
                    format!("{}.{:0width$}", self.coeff.abs(), 0, width = prec);
            } else {
                tmp = self.coeff.abs().to_string();
            }
        } else {
            let (int, frac) = match prec.cmp(&(self.n_frac_digits as usize)) {
                Ordering::Equal => i128_div_mod_floor(
                    self.coeff.abs(),
                    ten_pow(self.n_frac_digits),
                ),
                Ordering::Less => {
                    // Important: first round, then take abs() !
                    let coeff = i128_div_rounded(
                        self.coeff,
                        ten_pow(self.n_frac_digits - prec as u8),
                        None,
                    );
                    i128_div_mod_floor(coeff.abs(), ten_pow(prec as u8))
                }
                Ordering::Greater => {
                    let (int, frac) = i128_div_mod_floor(
                        self.coeff.abs(),
                        ten_pow(self.n_frac_digits),
                    );
                    (int, frac * ten_pow(prec as u8 - self.n_frac_digits))
                }
            };
            if prec > 0 {
                tmp = format!("{}.{:0width$}", int, frac, width = prec);
            } else {
                tmp = int.to_string();
            }
        }
        form.pad_integral(self.coeff >= 0, "", &tmp)
    }
/// Formats the value using the given formatter.
///
/// If the format specifies less fractional digits than
/// `self.n_frac_digits()`, the value gets rounded according to the
/// default rounding mode.
///
/// # Examples:
///
/// ```rust
/// # use core::fmt;
/// # use fpdec::{Dec, Decimal};
/// let d = Dec!(-1234.56);
/// assert_eq!(format!("{}", d), "-1234.56");
/// assert_eq!(format!("{:014.3}", d), "-000001234.560");
/// assert_eq!(format!("{:10.1}", d), "   -1234.6");
/// ```
Formats the value using the given formatter.
If the format specifies less fractional digits than
`self.n_frac_digits()`, the value gets rounded according to the
default rounding mode.
Formats the value using the given formatter . If the format specifies less fractional digits than ` self . n_frac_digits () ` the value gets rounded according to the default rounding mode .
fn fmt(&self, form: &mut fmt::Formatter<'_>) -> fmt::Result {
        let tmp: String;
        let prec = match form.precision() {
            Some(prec) => min(prec, MAX_N_FRAC_DIGITS as usize),
            None => self.n_frac_digits as usize,
        };
        if self.n_frac_digits == 0 {
            if prec > 0 {
                tmp =
                    format!("{}.{:0width$}", self.coeff.abs(), 0, width = prec);
            } else {
                tmp = self.coeff.abs().to_string();
            }
        } else {
            let (int, frac) = match prec.cmp(&(self.n_frac_digits as usize)) {
                Ordering::Equal => i128_div_mod_floor(
                    self.coeff.abs(),
                    ten_pow(self.n_frac_digits),
                ),
                Ordering::Less => {
                    // Important: first round, then take abs() !
                    let coeff = i128_div_rounded(
                        self.coeff,
                        ten_pow(self.n_frac_digits - prec as u8),
                        None,
                    );
                    i128_div_mod_floor(coeff.abs(), ten_pow(prec as u8))
                }
                Ordering::Greater => {
                    let (int, frac) = i128_div_mod_floor(
                        self.coeff.abs(),
                        ten_pow(self.n_frac_digits),
                    );
                    (int, frac * ten_pow(prec as u8 - self.n_frac_digits))
                }
            };
            if prec > 0 {
                tmp = format!("{}.{:0width$}", int, frac, width = prec);
            } else {
                tmp = int.to_string();
            }
        }
        form.pad_integral(self.coeff >= 0, "", &tmp)
    }
fn fmt ( & self , form : & mut fmt :: Formatter < ' _ > ) -> fmt :: Result { let tmp : String ; let prec = match form . precision ( ) { Some ( prec ) => min ( prec , MAX_N_FRAC_DIGITS as usize ) , None => self . n_frac_digits as usize , } ; if self . n_frac_digits == 0 { if prec > 0 { tmp = format ! ( " " self coeff abs ( ) 0 width prec ) ; } else { tmp = self . coeff . abs ( ) . to_string ( ) ; } } else { let ( int , frac ) = match prec . cmp ( & ( self . n_frac_digits as usize ) ) { Ordering :: Equal => i128_div_mod_floor ( self . coeff . abs ( ) , ten_pow ( self . n_frac_digits ) , ) , Ordering :: Less => { // Important: first round, then take abs() ! let coeff = i128_div_rounded ( self . coeff , ten_pow ( self . n_frac_digits - prec as u8 ) , None , ) ; i128_div_mod_floor ( coeff . abs ( ) , ten_pow ( prec as u8 ) ) } Ordering :: Greater => { let ( int , frac ) = i128_div_mod_floor ( self . coeff . abs ( ) , ten_pow ( self . n_frac_digits ) , ) ; ( int , frac * ten_pow ( prec as u8 - self . n_frac_digits ) ) } } ; if prec > 0 { tmp = format ! ( " " int frac width prec ) ; } else { tmp = int . to_string ( ) ; } } form . pad_integral ( self . coeff >= 0 , " " , & tmp ) }
Formats the value using the given formatter.
Formats the value using the given formatter .
&self
form
&mut fmt::Formatter<'_>
examples:
None
use core::fmt;
None
use fpdec::{dec, decimal};
None