Closed LarryBattle closed 11 years ago
Does this help .valueOf() produce better values when computing a/b where a and b are e notated?
.valueOf()
valueOf : function () { var top = this.numerator, bottom = this.denominator; if( 1e21 <= top && 1e21 <= bottom && top < Infinity && bottom < Infinity ){ var arr = (top).toString().split("e"), arr2 = (bottom).toString().split("e"); arr[1] = Number(arr[1]) + (-1 * arr2[1]); top = Number( arr.join("e") ); bottom = Number(arr2[0]); } return top/bottom; },
Implemented Ratio.simplifyENotation() for Ratio.prototype.valueOf() in Version 0.3.10. Need more testing to see how it goes though.
Ratio.simplifyENotation()
Ratio.prototype.valueOf()
Does this help
.valueOf()
produce better values when computing a/b where a and b are e notated?