Skip to content

Fractions

Arthur Guiot edited this page May 20, 2018 · 1 revision

To fraction

Convert any number n to a fraction like that:

t.toFraction(1/9) // [ '1', '9' ]
// Set the precision
t.toFraction(3.14159265358, 10) // [ '22', '7' ]

To decimal

t.toDec(...t.toFraction(1/9)) // ~0.1111111... => BigNumber
Clone this wiki locally