Ratio.js icon indicating copy to clipboard operation
Ratio.js copied to clipboard

Ratio.calc() function for more concise Ratio.js based calculations

Open m1sta opened this issue 11 years ago • 1 comments

It's be great if we could do something like...

var result = Ratio.calc("(0.1 + 0.2 + 1/3) * 12"); //result.toString is 3/40

much easier to write than...

var a = Ratio.parse(0.1).add(0.2).divide( Ratio(1,3).multiply(12) ); //result.toString is 3/40

m1sta avatar Feb 06 '14 00:02 m1sta

It's faster if you have javascript compute the value then send Ratio.js the result to form into a fraction. But I'll look into adding this in.

Ratio.parse( (0.1 + 0.2 + 1/3) * 12 ).simplify().toString() === "38/5"

LarryBattle avatar Feb 06 '14 06:02 LarryBattle