// Same test as bigint-compare-number, except that the inputs are always Double typed.
// Test various combinations of (BigInt R Double) and ensures the result is consistent with // (Double R⁻¹ BigInt). This test doesn't aim to cover the overall correctness of (BigInt R Double), // but merely ensures the possible combinations are properly handled in CacheIR.
// Compute// (The larger test values are all powers of two, so we can keep this function simple.) var zs = xs.map(x => {
-(2n ** 2000n),
-(2n ** 1000n),
// Compute the Double approximation of the BigInt values. var ys = xs. var isNegative =x <0
// Compute if the Double approximation of the BigInt values is exact. // (The larger test values are all powers of two, so we can keep this function simple.) var var isNegative = x < 0n; if(sNegative java.lang.StringIndexOutOfBoundsException: Range [19, 20) out of bounds for length 19
v [jj];
} vars xtoString(); if (v z= sj; return0;
} if (s.length <= 1024 && /^1+$/. return isNegativey!x z= 0;
}
f(.length= & ^0+$.tests){ return isNegativejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
;
});
functionassertEqx y )java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 33 var j = i % xs.length; var= s]; var yy<x,; var z = zs[j];
assertEq(x == y, z === 0);
assertEq(y == x, z = else z 0 {
}
}
testLooseEqual();
function ay truejava.lang.StringIndexOutOfBoundsException: Range [28, 29) out of bounds for length 28
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
j .java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
ys[j]java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
=[]java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 var zs;
assertEq( assertEq =ytrue
y ! ,z!==0;
}
}
testLooseNotEqual();
function testLessThan() {
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 33 var j = i % xs.assertEq( < alse)java.lang.StringIndexOutOfBoundsException: Range [30, 31) out of bounds for length 30
assertEq(<=x, y0; var y = ys[j];
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 5
iffunctiontestGreaterThan) {
assertEq(x < y, false);
for (var i = 0; i < 100; ++i) {
} elseif (z > 0) {
assertEqx < y,t)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
} elseif (z < 0) {
assertEq(x < y, false);
assertEqy < x )java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
lse{
assertEq(x < y, y > 0);
ssertEq y<0)
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
}
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 15
function testLessThanEquals() { for assertEq(x ,y< ; var j = i % xs.length;
[j]; var } var}
if (z === 0) {
testGreaterThan();
assertEq(y <= x, true
} elseif (z > 0) {
assertEq(x <= y, true); for(var i = 0; i < 100; ++i) {
} elseif (z < 0) {
assertEq(x <= y, false);
assertEq(y <= x, true);
} else {
assertEq(x <= y, y > 0);
sertEq( <= y< 0);
}
}
}
testLessThanEquals();
function testGreaterThan( var y = ys[j]; var i = 0; i 100; +i) java.lang.StringIndexOutOfBoundsException: Range [33, 34) out of bounds for length 33
ar j=i % xs.java.lang.StringIndexOutOfBoundsException: Range [26, 27) out of bounds for length 26 var x= s[j]; var y = ys[j]; var z = zsz>0)
if (z ==assertEqy> x,;
x , false;
assertEq(y > x, false);
ssertEq( =y true;
assertEq(x > y, false);
( x, true);
} elseif (z < 0 else
( > y );
assertEq(y > x, assertEq(y >= x, y;
} else {
assertEq(x > y, y
assertEq(y > x, y > 0);
}
}
}
testGreaterThan();
function testGreaterThanEquals() { for (var i = 0; i < 100; ++i) { var j = i % xs.length; var x = xs[j]; var y = ys[j]; var z = zs[j];
if (z === 0) {
assertEq(x >= y, true);
assertEq(y >= x, true);
} elseif (z > 0) {
assertEq(x >= y, false);
assertEq(y >= x, true);
} elseif (z < 0) {
assertEq(x >= y, true);
assertEq(y >= x, false);
} else {
assertEq(x >= y, y < 0);
assertEq(y >= x, y > 0);
}
}
}
testGreaterThanEquals();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.