This commit is contained in:
YHH
2020-06-17 22:40:49 +08:00
parent ccf8c4e107
commit e6d6c4199f
8 changed files with 33 additions and 35 deletions

View File

@@ -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 | {

View File

@@ -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).shiftLeft(32).toString()) | this.intToUint(y);
};
NumberDictionary.prototype.intToUint = function (i) {
if (i >= 0)

File diff suppressed because one or more lines are too long