Skip to main content

Module number

Module number 

Source
Expand description

JavaScript-compatible number parsers and formatters.

Functions§

format_number_js
ECMAScript ToString for f64 — spells NaN/Infinity/-Infinity and normalizes -0 to “0” (Rust’s default prints “inf” and keeps the sign).
parse_float_js
parse_int_js
JS-spec parseInt(s, radix) for an already-converted radix.
parse_int_with_radix
parseInt(s, radix) with the radix argument as JavaScript reads it: ToInt32, where 0 (including NaN and an omitted radix) means “detect a 0x prefix, else base 10”. Any other value outside 2–36 makes the result NaN.
string_to_number_js
JS-spec Number(s) / ToNumber on a string.
to_exponential_js
JS-spec Number#toExponential(fractionDigits). A NaN fractionDigits is the omitted-argument sentinel: use however many digits uniquely identify the value.
to_fixed_js
JS-spec Number#toFixed(digits).
to_precision_js
JS-spec Number#toPrecision(precision). A NaN precision is the omitted-argument sentinel: behave like plain toString.
to_string_radix_js
JS-spec Number#toString(radix) for radix 2–36.