/// Format the given satoshi amount in the given denomination.
///
/// Does not include the denomination.
Format the given satoshi amount in the given denomination.
Does not include the denomination.
Format the given satoshi amount in the given denomination . Does not include the denomination .
fn fmt_satoshi_in(
    satoshi: u64,
    negative: bool,
    f: &mut fmt::Write,
    denom: Denomination,
) -> fmt::Result {
    if negative {
        f.write_str("-")?;
    }
    if denom.precision() > 0 {
        // add zeroes in the end
        let width = denom.precision() as usize;
        write!(f, "{}{:0width$}", satoshi, 0, width = width)?;
    } else if denom.precision() < 0 {
        // need to inject a comma in the number
        let nb_decimals = denom.precision().abs() as usize;
        let real = format!("{:0width$}", satoshi, width = nb_decimals);
        if real.len() == nb_decimals {
            write!(f, "0.{}", &real[real.len() - nb_decimals..])?;
        } else {
            write!(
                f,
                "{}.{}",
                &real[0..(real.len() - nb_decimals)],
                &real[real.len() - nb_decimals..]
            )?;
        }
    } else {
        // denom.precision() == 0
        write!(f, "{}", satoshi)?;
    }
    Ok(())
}
fn fmt_satoshi_in ( satoshi : u64 , negative : bool , f : & mut fmt :: Write , denom : Denomination , ) -> fmt :: Result { if negative { f . write_str ( " " ) ? ; } if denom . precision ( ) > 0 { // add zeroes in the end let width = denom . precision ( ) as usize ; write ! ( f " " satoshi 0 width width ) ? ; } else if denom . precision ( ) < 0 { // need to inject a comma in the number let nb_decimals = denom . precision ( ) . abs ( ) as usize ; let real = format ! ( " " satoshi width nb_decimals ) ; if real . len ( ) == nb_decimals { write ! ( f " " real [ real len ( ) nb_decimals ] ) ? ; } else { write ! ( f " " real [ 0 ( real len ( ) nb_decimals ) ] real [ real len ( ) nb_decimals ] ) ? ; } } else { // denom.precision() == 0 write ! ( f " " satoshi ) ? ; } Ok ( ( ) ) }
Format the given satoshi amount in the given denomination.
Format the given satoshi amount in the given denomination .
satoshi
u64
negative
bool
f
&mut fmt::Write
denom
Denomination