Ext.: http://bbs.csdn.net/topics/360259080
Floating-point addition operations
function Floatadd (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;
}
Floating-point subtraction operations
function Floatsub (ARG1,ARG2) {
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));
Dynamic control accuracy length
N= (R1>=R2) r1:r2;
Return ((arg1*m-arg2*m)/m). ToFixed (n);
}
Floating-point multiplication operations
function Floatmul (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);
}
Floating-point division operations
function Floatdiv (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 (R1/R2) *pow (10,T2-T1);
}
}
There is no way. JS comes with the bug. Take it to wing-BA.
JS float data added, some correct, some wrong