foundry_common_fmt::exp

Function to_exp_notation

Source
pub fn to_exp_notation(
    value: U256,
    precision: usize,
    trim_end_zeros: bool,
    sign: Sign,
) -> String
Expand description

Returns the number expressed as a string in exponential notation with the given precision (number of significant figures), optionally removing trailing zeros from the mantissa.

Examples:

precision = 4, trim_end_zeroes = false
    1234124124 -> 1.234e9
    10000000 -> 1.000e7
precision = 3, trim_end_zeroes = true
    1234124124 -> 1.23e9
    10000000 -> 1e7