a fraction arithmetic library written in javascript.
npm install fractional
varFraction=require('fractional').Fraction// Create a new fraction with the new keyword:(newFraction(7,3)).multiply(newFraction(1,2)).toString()// 1 1/6(newFraction(7,3)).divide(newFraction(1,2)).toString()// 4 2/3(newFraction(3,10)).add(newFraction(5,9)).toString()// 77/90(newFraction(0.25)).add(newFraction(1,6)).toString()// 5/12(newFraction(0.35)).subtract(newFraction(1,4)).toString()// 1/10(newFraction(5,10)).numerator// 5(newFraction(3,4)).denominator// 4Fractional provides a simple interface to add, subtract, multiply, and divide fractions.
Fractions are represented in most-normalized form.
MIT
Erik Garrison erik.garrison@gmail.com