Browse Source

修改尾数进位方法,以前的算法进多了

zhangyin 7 years ago
parent
commit
84dcb35b62
1 changed files with 8 additions and 1 deletions
  1. 8 1
      public/web/scMathUtil.js

+ 8 - 1
public/web/scMathUtil.js

@@ -49,6 +49,13 @@ let scMathUtil = {
         };
         return sign + result;
     },
+    zeroString: function(length){
+        let result = '';
+        for (let i = 0; i < length; i++){
+            result = result + '0';
+        };
+        return result;
+    },    
     incMantissa: function(bin){
         let result = bin;
         let iDot = bin.indexOf('.');
@@ -59,7 +66,7 @@ let scMathUtil = {
             if (num === 0){
                 num = 1;
                 let bin1 = bin.substring(0, i);
-                let bin2 = bin.substring(i + 1, iLength);
+                let bin2 = zeroString(iLength - (i + 1));//bin.substring(i + 1, iLength);
                 result = bin1 + num.toString() + bin2;
                 break;
             }