LarryBattle / Ratio.js

Rational numbers for Javascript
http://larrybattle.github.com/Ratio.js/
MIT License
113 stars 9 forks source link

Possible ratio.js plugins #8

Open LarryBattle opened 12 years ago

LarryBattle commented 12 years ago

Could you try to add these enhancements as a plugin?

LarryBattle commented 11 years ago

For toFixed(), I think Ratio.parse().valueOf().toFixed() should work well, unless if there are too many errors with the division.

For example,

(12000/31).toFixed(20) === "387.09677419354841276800"
but should be 
(12000/31).toFixed(20) === "387.09677419354838709677"
LarryBattle commented 11 years ago

For tofixed(), you could try something like decimal expansion. Article: http://bateru.com/news/2012/05/code-of-the-day-javascript-decimal-expansion-a-k-a-division/ Bug in article, doesn't support scientific notated values.