Fracturize
Installing
npm install https://github.com/ibrido90/fracturize.git
npm install fracturize
Test
npm test
Usage
var Fraction = var a = 12console //prints 1/2var b = 52console //prints 5/2var c = baconsole //prints 5/1var c = abconsole //prints 1/5var one = console //prints 1/1 var wrong = 10 -> Error
Fraction accept 0,1(just numerator) or 2(numerator,denominator) arguments. This could be at their times Fraction objects or numbers
Note: in constructor you can specify the optional boolean force wich allow you to decide if force fraction semplification:
105 // 2/1105false // 2/1105true // 10/5
Operations
Sum
a // a + b -> 3/1
Subtraction
a) // a - b -> -2/1
Multiply
a // a * b -> 5/4
Division
a // a / b -> 1/5
Conversion
You can convert a Fraction object to its relative value by executing it
console // num / den -> prints 0.5
or to its string rappresentation with
a // -> "1/2"
Utilities
Maximum
Fraction // MAX(a,b) -> prints 5/2
Minimum
Fraction // MAX(a,b) -> prints 1/2
isBetween
c// a < c < b -> falseone// a < one < b -> true