我试图在不影响结果准确性的情况下,在JavaScript eval()函数中消除此舍入误差。在格式编号函数FormatNumber(strnum)中,我放入了CheckEpsilon(strnum),它测试number的“右尾”是否大于epsilon (假设epsilon的值是1e-9,就像在/ If y (or 1-y) is smaller than epsilon we round strnum
if (y<epsilon
我的一般情况是比较价格,可以有0.5美分的准确性。59.005,而不是59.395。我选择的epsilon是否适合这些情况?true : Math.abs(a - b) < EPSILON;
* Returns true if two doubles are considered equal.Test if the difference of first minus second is greater then
* a given double (<e
----- double epsilonbase/2; while( answer - ( power(answer,root) - base)/(root*power(answer,root-1) ) > epsilonContinue formula until error is less than <