fix long
This commit is contained in:
6
source/bin/framework.d.ts
vendored
6
source/bin/framework.d.ts
vendored
@@ -559,11 +559,11 @@ declare interface Long {
|
||||
divide(divisor: any): Long;
|
||||
equals(other: any): any;
|
||||
not(): any;
|
||||
toString(radix: any): string;
|
||||
toString(radix?: any): string;
|
||||
isZero(): any;
|
||||
isNegative(): any;
|
||||
multiply(multiplier: any): Long;
|
||||
shiftRight(numBits: any): any;
|
||||
shiftRight(numBits: any): Long;
|
||||
shiftRightUnsigned(numBits: any): any;
|
||||
subtract(subtrahend: any): Long;
|
||||
greaterThan(other: any): any;
|
||||
@@ -593,7 +593,7 @@ declare class Long {
|
||||
static max_value: Long;
|
||||
static one: Long;
|
||||
static neg_one: Long;
|
||||
constructor(low: number, high: number, unsigned?: boolean);
|
||||
constructor(low: number, high: number, unsigned: boolean);
|
||||
shiftLeft(numBits: number | Long): Long;
|
||||
static fromBits(lowBits: any, highBits: any, unsigned: any): Long;
|
||||
static fromValue(val: number | string | {
|
||||
|
||||
@@ -2613,7 +2613,6 @@ var Flags = (function () {
|
||||
}());
|
||||
var Long = (function () {
|
||||
function Long(low, high, unsigned) {
|
||||
if (unsigned === void 0) { unsigned = true; }
|
||||
this.low = low | 0;
|
||||
this.high = high | 0;
|
||||
this.unsigned = !!unsigned;
|
||||
@@ -2841,8 +2840,8 @@ Long.prototype.divide = function (divisor) {
|
||||
return Long.one;
|
||||
else {
|
||||
var halfThis = i.shiftRight(1);
|
||||
approx = halfThis.div(divisor).shl(1);
|
||||
if (approx.eq(Long.zero)) {
|
||||
approx = halfThis.divide(divisor).shiftLeft(1);
|
||||
if (approx.equals(Long.zero)) {
|
||||
return divisor.isNegative() ? Long.one : Long.neg_one;
|
||||
}
|
||||
else {
|
||||
@@ -2860,7 +2859,7 @@ Long.prototype.divide = function (divisor) {
|
||||
return i.negate().divide(divisor).negate();
|
||||
}
|
||||
else if (divisor.isNegative())
|
||||
return this.div(divisor.negate()).neg();
|
||||
return i.divide(divisor.negate()).negate();
|
||||
res = Long.zero;
|
||||
}
|
||||
else {
|
||||
@@ -2878,7 +2877,7 @@ Long.prototype.divide = function (divisor) {
|
||||
var log2 = Math.ceil(Math.log(approx) / Math.LN2), delta = (log2 <= 48) ? 1 : Math.pow(2, log2 - 48), approxRes = Long.fromNumber(approx), approxRem = approxRes.multiply(divisor);
|
||||
while (approxRem.isNegative() || approxRem.greaterThan(rem)) {
|
||||
approx -= delta;
|
||||
approxRes = Long.fromNumber(approx, this.unsigned);
|
||||
approxRes = Long.fromNumber(approx, i.unsigned);
|
||||
approxRem = approxRes.multiply(divisor);
|
||||
}
|
||||
if (approxRes.isZero())
|
||||
@@ -2924,7 +2923,7 @@ Long.prototype.greaterThan = function (other) {
|
||||
};
|
||||
Long.prototype.compare = function (other) {
|
||||
var i = this;
|
||||
if (typeof (other) === "number")
|
||||
if (typeof other === "number")
|
||||
other = Long.fromValue(other);
|
||||
if (i.equals(other))
|
||||
return 0;
|
||||
@@ -4251,7 +4250,7 @@ var NumberDictionary = (function () {
|
||||
this._store = new Map();
|
||||
}
|
||||
NumberDictionary.prototype.getKey = function (x, y) {
|
||||
return Number(Long.fromValue(x).shiftLeft(32).toString(10)) | this.intToUint(y);
|
||||
return Number(Long.fromNumber(x << 32).toString()) | this.intToUint(y);
|
||||
};
|
||||
NumberDictionary.prototype.intToUint = function (i) {
|
||||
if (i >= 0)
|
||||
|
||||
2
source/bin/framework.min.js
vendored
2
source/bin/framework.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -5,11 +5,11 @@ declare interface Long {
|
||||
divide(divisor): Long;
|
||||
equals(other);
|
||||
not();
|
||||
toString(radix): string;
|
||||
toString(radix?): string;
|
||||
isZero();
|
||||
isNegative();
|
||||
multiply(multiplier): Long;
|
||||
shiftRight(numBits);
|
||||
shiftRight(numBits): Long;
|
||||
shiftRightUnsigned(numBits);
|
||||
subtract(subtrahend): Long;
|
||||
greaterThan(other);
|
||||
@@ -42,7 +42,7 @@ class Long {
|
||||
public static one = Long.fromInt(1);
|
||||
public static neg_one = Long.fromInt(-1);
|
||||
|
||||
constructor(low: number, high: number, unsigned: boolean = true){
|
||||
constructor(low: number, high: number, unsigned: boolean){
|
||||
this.low = low | 0;
|
||||
this.high = high | 0;
|
||||
this.unsigned = !!unsigned;
|
||||
@@ -216,7 +216,7 @@ Long.prototype.not = function(){
|
||||
return Long.fromBits(~i.low, ~i.high, i.unsigned);
|
||||
}
|
||||
|
||||
Long.prototype.toString = function(radix){
|
||||
Long.prototype.toString = function(radix?){
|
||||
let i = this as Long;
|
||||
radix = radix || 10;
|
||||
if (radix < 2 || 36 < radix)
|
||||
@@ -271,7 +271,7 @@ Long.prototype.divide = function(divisor: number | Long){
|
||||
|
||||
if (i.isZero())
|
||||
return i.unsigned ? Long.uzero : Long.zero;
|
||||
let approx, rem: Long, res;
|
||||
let approx: number | Long, rem: Long, res;
|
||||
if (!i.unsigned) {
|
||||
if (i.equals(Long.min_value)) {
|
||||
if (divisor.equals(Long.one) || divisor.equals(Long.neg_one))
|
||||
@@ -279,9 +279,9 @@ Long.prototype.divide = function(divisor: number | Long){
|
||||
else if (divisor.equals(Long.min_value))
|
||||
return Long.one;
|
||||
else {
|
||||
var halfThis = i.shiftRight(1);
|
||||
approx = halfThis.div(divisor).shl(1);
|
||||
if (approx.eq(Long.zero)) {
|
||||
let halfThis = i.shiftRight(1);
|
||||
approx = halfThis.divide(divisor).shiftLeft(1);
|
||||
if (approx.equals(Long.zero)) {
|
||||
return divisor.isNegative() ? Long.one : Long.neg_one;
|
||||
} else {
|
||||
rem = i.subtract(divisor.multiply(approx));
|
||||
@@ -296,7 +296,7 @@ Long.prototype.divide = function(divisor: number | Long){
|
||||
return i.negate().divide(divisor.negate());
|
||||
return i.negate().divide(divisor).negate();
|
||||
} else if (divisor.isNegative())
|
||||
return this.div(divisor.negate()).neg();
|
||||
return i.divide(divisor.negate()).negate();
|
||||
res = Long.zero;
|
||||
} else {
|
||||
if (!divisor.unsigned)
|
||||
@@ -318,7 +318,7 @@ Long.prototype.divide = function(divisor: number | Long){
|
||||
approxRem = approxRes.multiply(divisor);
|
||||
while (approxRem.isNegative() || approxRem.greaterThan(rem)) {
|
||||
approx -= delta;
|
||||
approxRes = Long.fromNumber(approx, this.unsigned);
|
||||
approxRes = Long.fromNumber(approx, i.unsigned);
|
||||
approxRem = approxRes.multiply(divisor);
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ Long.prototype.subtract = function(subtrahend: number | Long){
|
||||
let i = this as Long;
|
||||
if (typeof subtrahend === "number")
|
||||
subtrahend = Long.fromValue(subtrahend);
|
||||
return i.add((subtrahend as Long).negate());
|
||||
return i.add(subtrahend.negate());
|
||||
}
|
||||
|
||||
Long.prototype.greaterThan = function(other){
|
||||
@@ -368,7 +368,7 @@ Long.prototype.greaterThan = function(other){
|
||||
|
||||
Long.prototype.compare = function(other: number | Long){
|
||||
let i = this as Long;
|
||||
if (typeof (other) === "number")
|
||||
if (typeof other === "number")
|
||||
other = Long.fromValue(other);
|
||||
if (i.equals(other))
|
||||
return 0;
|
||||
|
||||
@@ -132,7 +132,7 @@ class NumberDictionary {
|
||||
* @param y
|
||||
*/
|
||||
private getKey(x: number, y: number): number {
|
||||
return Number(Long.fromValue(x).shiftLeft(32).toString(10)) | this.intToUint(y);
|
||||
return Number(Long.fromNumber(x << 32).toString()) | this.intToUint(y);
|
||||
}
|
||||
|
||||
private intToUint(i) {
|
||||
|
||||
Reference in New Issue
Block a user