value =add(100.9,2.4449);functionadd(arg1, arg2){var res1, res2, m;try{
res1 = arg1.toString().split(".")[1].length;}catch(e){
res1 =0;}try{
res2 = arg2.toString().split(".")[1].length;}catch(e){
res2 =0;}
m = Math.pow(10, Math.max(res1, res2));return(arg1 * m + arg2 * m)/ m;}
2. 减法
value =minus(100.9,2.4449);functionminus(arg1, arg2){var res1, res2, m, n;try{
res1 = arg1.toString().split(".")[1].length;}catch(e){
res1 =0;}try{
res2 = arg2.toString().split(".")[1].length;}catch(e){
res2 =0;}
m = Math.pow(10, Math.max(res1, res2));
n =(res1 >= res2)? res1 : res2;return((arg1 * m - arg2 * m)/ m).toFixed(n);}
3. 乘法
value =multi(100.9,2.4449);functionmulti(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){}returnNumber(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m);}