js> load('fraction-0.2.js'); // creates the global Fraction object
js> (new Fraction(7,3)).multiply(new Fraction(1,2))
js> (new Fraction(7,3)).divide(new Fraction(1,2))
js> (new Fraction(3,10)).add(new Fraction(5,9))
js> (new Fraction(0.25)).add(new Fraction(1,6))
js> (new Fraction(0.35)).subtract(new Fraction(1,4))
(This is the best way to get fraction.js)
- Each Fraction object contains two members: denominator and
- Fractions are stored following all operations in normalized
(numerator and denominator are divided by their greatest common
- Fractions methods can take any type of number or other
- Fractions can be created from any kind of number (e.g. f = new
may produce unintended results if fractions are initialized with the
decimal equivalents of numbers such as 1/3, 1/9, etc.
0.3 2010-02-18 - Rounding issue resolution and speed tweak.
0.2 2009-11-19 - Major cleanup, resolution of namespace issues.
0.1 2009-10-30 - Basic functionality. Issues with namespacing (use of array mixins, other problems).