moonnum.
PlaygroundRun the library

The sheet, working itself out

Four sums worked on the page. Nothing here is re-implemented in JavaScript: each panel calls this library, compiled to JavaScript by the docs workflow, and prints the answer it returned.

loading the engine…

one

A fraction, written out

Every fraction is a terminating or a repeating decimal, and which one it is depends on the denominator. Rounding is done once, at the place you ask for.


      

two

Pi, from a series

No table of digits: the value is computed at the width that holds the places you ask for, by Machin's formula, and rounded once.


      

three

The format language

One specification string, any kind of number. Fill and alignment, sign, the alternate form, grouping, precision, and a type letter — d, f, e, %, x, b and the rest.


      

four

A double, taken apart

A float is not the decimal it looks like. This is the value it really holds, the shortest text that reads back as it, and the bits in hexadecimal.


      

Where the numbers come from. The engine is src/examples/browser, built for JavaScript into docs/engine/ by the docs workflow. It is not checked in: the page you are reading was published with a build of the library at the version in the repository.