rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js
changeset 1857 f1344425bcb1
parent 1800 65cab8539582
child 1858 4dea14fafc31
     1.1 --- a/rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js	Fri Feb 27 19:28:07 2015 +0100
     1.2 +++ b/rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js	Mon Jan 25 06:40:40 2016 +0100
     1.3 @@ -1,25 +1,27 @@
     1.4  // empty line needed here
     1.5  
     1.6  (function(numberPrototype) {
     1.7 -    numberPrototype.add32 = function(x) {
     1.8 -        return (this + x) | 0;
     1.9 -    };
    1.10 -    numberPrototype.sub32 = function(x) {
    1.11 -        return (this - x) | 0;
    1.12 +    function add32(x, y) {
    1.13 +        return (x + y) | 0;
    1.14      };
    1.15      numberPrototype.mul32 = function(x) {
    1.16          return (((this * (x >> 16)) << 16) + this * (x & 0xFFFF)) | 0;
    1.17      };
    1.18 -    numberPrototype.neg32 = function() {
    1.19 -        return (-this) | 0;
    1.20 -    };
    1.21 +    numberPrototype.div32 = function(x) {
    1.22 +        if (x === 0) {
    1.23 +            __handleDivByZero();
    1.24 +        }
    1.25  
    1.26 -    numberPrototype.toInt8 = function() {
    1.27 -        return (this << 24) >> 24;
    1.28 -    };
    1.29 -    numberPrototype.toInt16 = function() {
    1.30 -        return (this << 16) >> 16;
    1.31 -    };
    1.32 +        return (this / x) | 0;
    1.33 +    }
    1.34 +
    1.35 +    numberPrototype.mod32 = function(x) {
    1.36 +        if (x === 0) {
    1.37 +            __handleDivByZero();
    1.38 +        }
    1.39 +
    1.40 +        return (this % x);
    1.41 +    }
    1.42  
    1.43      var __m32 = 0xFFFFFFFF;
    1.44  
    1.45 @@ -35,9 +37,6 @@
    1.46      numberPrototype.high32 = function() {
    1.47          return this.hi ? this.hi : (Math.floor(this / (__m32 + 1))) | 0;
    1.48      };
    1.49 -    numberPrototype.toInt32 = function() {
    1.50 -        return this | 0;
    1.51 -    };
    1.52      numberPrototype.toFP = function() {
    1.53          return this.hi ? this.hi * (__m32 + 1) + this : this;
    1.54      };
    1.55 @@ -137,7 +136,7 @@
    1.56  
    1.57          var m1 = this.high32().mul32(x);
    1.58          var m2 = this.mul32(x.high32());
    1.59 -        hi = hi.add32(m1).add32(m2);
    1.60 +        hi = add32(add32(hi, m1), m2);
    1.61  
    1.62          return hi.next32(low);
    1.63      };
    1.64 @@ -225,16 +224,6 @@
    1.65          }
    1.66      };
    1.67  
    1.68 -    // keeping for compatibility with generated bck2brwsr.js library files
    1.69 -    // not used since 0.14
    1.70 -    numberPrototype.compare = function(x) {
    1.71 -        if (this == x) {
    1.72 -            return 0;
    1.73 -        } else {
    1.74 -            return (this < x) ? -1 : 1;
    1.75 -        }
    1.76 -    };
    1.77 -
    1.78      numberPrototype.compare64 = function(x) {
    1.79          if (this.high32() === x.high32()) {
    1.80              return (this < x) ? -1 : ((this > x) ? 1 : 0);
    1.81 @@ -490,22 +479,6 @@
    1.82          }
    1.83      }
    1.84  
    1.85 -    numberPrototype.div32 = function(x) {
    1.86 -        if (x === 0) {
    1.87 -            __handleDivByZero();
    1.88 -        }
    1.89 -
    1.90 -        return (this / x) | 0;
    1.91 -    }
    1.92 -
    1.93 -    numberPrototype.mod32 = function(x) {
    1.94 -        if (x === 0) {
    1.95 -            __handleDivByZero();
    1.96 -        }
    1.97 -
    1.98 -        return (this % x);
    1.99 -    }
   1.100 -
   1.101      numberPrototype.div64 = function(x) {
   1.102          var negateResult = false;
   1.103          var u, v;