Skip to main content

number_to_string

Function number_to_string 

Source
pub fn number_to_string(value: f64) -> String
Expand description

ToString applied to a number.

The thresholds are the ones the spec’s Number::toString uses: exponential form below 1e-6 and from 1e21 up, decimal form in between. Within the decimal range Rust’s shortest-round-trip formatter already agrees with JavaScript digit for digit — including the notorious 0.30000000000000004 — so only the exponent spelling has to be normalised.