Skip to main content

precision_from_str

Function precision_from_str 

Source
pub fn precision_from_str(s: &str) -> u8
Expand description

Returns the decimal precision inferred from the given string.

For scientific notation (e.g., “1e-300”, “1.5e-2”), the precision accounts for both the mantissa’s fractional digits and the signed exponent: max(0, fractional_digits - exponent), clamped to u8::MAX (255).

§Panics

Panics if the input string is malformed (e.g., “1e-” with no exponent value, or non-numeric exponents like “1e-abc”).