emul/src/main/resources/org/apidesign/vm4brwsr/emul/java_lang_Number.js
brancharithmetic
changeset 593 b42911b78a16
parent 582 8e546d108658
parent 592 5e13b1ac2886
child 594 035fcbd7a33c
     1.1 --- a/emul/src/main/resources/org/apidesign/vm4brwsr/emul/java_lang_Number.js	Fri Jan 25 11:00:52 2013 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,71 +0,0 @@
     1.4 -// empty line needed here
     1.5 -Number.prototype.add32 = function(x) { return (this + x) | 0; };
     1.6 -Number.prototype.sub32 = function(x) { return (this - x) | 0; };
     1.7 -Number.prototype.mul32 = function(x) { 
     1.8 -    return (((this * (x >> 16)) << 16) + this * (x & 0xFFFF)) | 0;
     1.9 -};
    1.10 -
    1.11 -Number.prototype.toInt8 = function()  { return (this << 24) >> 24; };
    1.12 -Number.prototype.toInt16 = function() { return (this << 16) >> 16; };
    1.13 -
    1.14 -var Long = function(low, hi) {
    1.15 -    this.low = low;
    1.16 -    this.hi = hi;
    1.17 -};
    1.18 -
    1.19 -function LongFromNumber(x) {
    1.20 -    return new Long(x % 0xFFFFFFFF, Math.floor(x / 0xFFFFFFFF));
    1.21 -};
    1.22 -
    1.23 -function MakeLong(x) {
    1.24 -    if ((x.hi == undefined) && (x.low == undefined)) {
    1.25 -        return LongFromNumber(x);
    1.26 -    }
    1.27 -    return x;
    1.28 -};
    1.29 -
    1.30 -Long.prototype.toInt32 = function() { return this.low | 0; };
    1.31 -Long.prototype.toFP = function() { return this.hi * 0xFFFFFFFF + this.low; };
    1.32 -
    1.33 -Long.prototype.toString = function() {
    1.34 -    return String(this.toFP());
    1.35 -};
    1.36 -
    1.37 -Long.prototype.valueOf = function() {
    1.38 -    return this.toFP();
    1.39 -};
    1.40 -
    1.41 -Long.prototype.compare64 = function(x) {
    1.42 -    if (this.hi == x.hi) {
    1.43 -        return (this.low == x.low) ? 0 : ((this.low < x.low) ? -1 : 1);
    1.44 -    }
    1.45 -    return (this.hi < x.hi) ? -1 : 1;
    1.46 -};
    1.47 -
    1.48 -Long.prototype.add64 = function(x) {
    1.49 -    low = this.low + x.low;
    1.50 -    carry = 0;
    1.51 -    if (low > 0xFFFFFFFF) {
    1.52 -        carry = 1;
    1.53 -        low -= 0xFFFFFFFF;
    1.54 -    }
    1.55 -    hi = (this.hi + x.hi + carry) & 0xFFFFFFFF;
    1.56 -    return new Long(low, hi);
    1.57 -};
    1.58 -
    1.59 -Long.prototype.div64 = function(x) {
    1.60 -    return LongFromNumber(Math.floor(this.toFP() / x.toFP()));
    1.61 -};
    1.62 -
    1.63 -Long.prototype.shl64 = function(x) {
    1.64 -    if (x > 32) {
    1.65 -        hi = (this.low << (x - 32)) & 0xFFFFFFFF;
    1.66 -        low = 0;
    1.67 -    } else {
    1.68 -        hi = (this.hi << x) & 0xFFFFFFFF;
    1.69 -        low_reminder = this.low >> x;
    1.70 -        hi |= low_reminder;
    1.71 -        low = this.low << x;
    1.72 -    }
    1.73 -    return new Long(low, hi);
    1.74 -};