reason:JS in accordance with the 2 to deal with decimal subtraction, on the basis of arg1 arg2 precision extension or reverse expansion matching, so will appear as follows.
JavaScript (JS) decimal point subtraction problem, is a JS bug such as 0.3*1 = 0.2999999999, the following list can be perfect to find the corresponding accuracy of the four JS algorithm
function Accdiv (arg1,arg2) {var t1=0,t2=0,r1,r2; Try{t1=arg1.tostring (). Split (".") [1].length}catch (e) {} try{t2=arg2.tostring (). Split (".") [1].length}catch (e) {} with (Math) {R1=number (arg1.tostring (). Replace (".", ")) R2=number (Arg2.tostring (). Replace (".
"," ")) return Accmul ((R1/R2), pow (10,T2-T1));
} * * * * * hovertree.com///Multiplication function Accmul (arg1,arg2) {var m=0,s1=arg1.tostring (), s2=arg2.tostring (); Try{m+=s1.split (".") [1].length}catch (e) {} try{m+=s2.split (".") [1].length}catch (e) {} return Number (S1.replace (".", "")) *number (S2.replace (".", ""))/math.pow (10,M)}//addition Functio
n Accadd (arg1,arg2) {var r1,r2,m; Try{r1=arg1.tostring (). Split (".") [1].length}catch (e) {r1=0} try{r2=arg2.tostring (). Split (".") [1].length}catch (e) {r2=0} m=math.pow (10,math.max (R1,R2)) return (arg1*m+arg2*m)/m}//Subtraction function subtr (arg1,arg
2) {var r1,r2,m,n; Try{r1=arg1.tostring (). Split (".") [1].length}catch (e) {r1=0} try{r2=arg2.tostring (). Split(".")
[1].length}catch (e) {r2=0} m=math.pow (10,math.max (R1,R2));
N= (R1>=R2) r1:r2;
Return ((arg1*m-arg2*m)/m). ToFixed (n); }
Above this JavaScript decimal precision loss of the perfect solution is to share all the content of the small, hope to give you a reference, but also hope that we support the cloud habitat community.