Skip to main content

Module js_number

Module js_number 

Source
Expand description

ECMAScript Number::toString for binary64.

The JavaScript frontend keeps a Number literal as String(value), the text JavaScript prints, so both runtimes agree on it. Rust’s {:e} gives the shortest digits that read back as the value; ECMAScript picks the even neighbour where Rust rounds a tie away from zero.

The emitted Rust prelude (ml_number::js_number) is the same algorithm.

Functions§

js_number
String(x) for a JavaScript Number x.
js_number_literal
String(Number(text)) for the text of a JavaScript numeric literal without separators or suffix: decimal, or 0x, 0o, 0b integers.