Variables stored in JavaScript do not distinguish between number and float types, and are stored in the same way as float;
JavaScript uses the 64bit floating-point format defined by the IEEE 754-2008 standard to store number,decimal64 corresponding to a portion length of 10 and a small tree part length of 16;
JavaScript decimal operations can appear imprecise.
//addition Operation varAccadd =function(num1,num2) {varn1,n2,m; Try{N1= Num1.tostring (). Split (".") [1].length; }Catch(e) {N1= 0; } Try{n2= Num2.tostring (). Split (".") [1].length; }Catch(e) {n2= 0; } m= Math.pow (10, Math.max (N1,N2)); return(Num1*m + num2*m)/m; } //Subtraction Operations varSuntr =function(num1,num2) {varN1,n2,m,n; Try{N1= Num1.tostring (). Split (".") [1].length; }Catch(e) {N1= 0; } Try{n2= Num2.tostring (). Split (".") [1].length; }Catch(e) {n2= 0; } m= Math.pow (10, Math.max (N1,N2)); N= (N1 > N2)?n1:n2; return((num1*m-num2*m)/m). ToFixed (n); } //Multiplication Operations varAccmul =function(num1,num2) {varm = 0, n1,n2, S1=num1.tostring (), S2=num2.tostring (); Try{m+ = S1.split (".") [1].length; }Catch(e) {}Try{m+ = S2.split (".") [1].length; }Catch(e) {} n1= Number (S1.replace (".", "")); N2= Number (S2.replace (".", "")); returnN1 * N2/MATH.POW (10, M); } //Division Operation varAccdivi =function(num1,num2) {varS1 = 0,S2 = 0, n1,n2; Try{S1= Num1.tostring (). Split (".") [1].length; }Catch(e) {}Try{s2= Num2.tostring (). Split (".") [1].length; }Catch(e) {} with(Math) {N1= Number (num1.tostring (). Replace (".", "")); N2= Number (num2.tostring (). Replace (".", "")); return(N1/N2) *math.pow (10,S2-S1); } }
overriding JavaScript floating-point arithmetic