Every number a fraction under the 4096-bit limit (closes #3)
check / check (push) Successful in 1m11s
check / check (push) Successful in 1m11s
go/constant never rounds an integer, and x^0 returned one, so whole numbers built from it escaped the 4096-bit limit: (((2^0+2^0)^4096)^4096)^4096 asked for about 69 billion bits and stalled the bot. A power now starts from the fraction 1, and a number is exact only as a fraction whose numerator and denominator are below 4096 bits, which also refuses a literal that go/constant reads exactly past the limit, such as 1e-1233. The bounded-work test holds the tower and the other short inputs tried against the change. Model: opus-5-5
This commit is contained in:
@@ -130,6 +130,8 @@ func TestEvaluateModulo(t *testing.T) {
|
||||
// Both operands and their quotient are held exactly, but y times
|
||||
// the whole part of x/y is too large to be.
|
||||
"(5^860*3^630/7) % (5^860/2^998/2^998)": "0.5179219763783696",
|
||||
// A whole number made from x^0, just below the 4096-bit limit.
|
||||
"(3^0 + 3^0 + 3^0)^2583 % 10": "7",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -243,6 +245,11 @@ func TestEvaluateOutOfRange(t *testing.T) {
|
||||
"0.1^800 * 0.1^800": calc.ErrOutOfRange,
|
||||
// Both operands are held exactly, but their quotient is not.
|
||||
"3^1365 % 7^-1000": calc.ErrOutOfRange,
|
||||
// The same limit for a whole number made from x^0, which
|
||||
// go/constant would hold as an integer and never round, and for
|
||||
// a literal it reads exactly as a fraction past the limit.
|
||||
"(2^0 + 2^0)^4095 % 10": calc.ErrOutOfRange,
|
||||
"1e-1233 * 0": calc.ErrOutOfRange,
|
||||
// go/constant reads this literal as 0.
|
||||
"1e-999999999": calc.ErrOutOfRange,
|
||||
"1 / 1e-999999999": calc.ErrOutOfRange,
|
||||
@@ -288,6 +295,20 @@ func TestEvaluateBoundsWork(t *testing.T) {
|
||||
{in: strings.Repeat("9^", 127) + "9", err: calc.ErrOutOfRange},
|
||||
// The largest power of 3 computed exactly, as often as fits.
|
||||
{in: "0" + strings.Repeat("*3^2583", 36), want: "0"},
|
||||
// Whole numbers made from x^0, through each operation. Held as
|
||||
// integers, which go/constant never rounds, they would escape
|
||||
// the 4096-bit limit: the first needs about 69 billion bits.
|
||||
{in: "(((2^0+2^0)^4096)^4096)^4096", err: calc.ErrOutOfRange},
|
||||
{in: "(((0^0+0^0)^4096)^4096)^4096", err: calc.ErrOutOfRange},
|
||||
{in: "(((-2^0-2^0)^4096)^4096)^4096", err: calc.ErrOutOfRange},
|
||||
{in: "((2^0+2^0)^4000*(2^0+2^0)^4000)^4096", err: calc.ErrOutOfRange},
|
||||
{in: "((((2^0+2^0)/2^0)^4096)^4096)^4096", err: calc.ErrOutOfRange},
|
||||
{in: "((((2^0+2^0) % 3)^4096)^4096)^4096", err: calc.ErrOutOfRange},
|
||||
{in: "(((2^0+2^0)^4096)^4096)^4096 * 0", err: calc.ErrOutOfRange},
|
||||
// A fraction whose numerator and denominator are both just below
|
||||
// the limit, and a literal whose exponent is too large to read.
|
||||
{in: "(3^2583/5^1760)^4096", err: calc.ErrOutOfRange},
|
||||
{in: "1e99999999999999999999", err: calc.ErrOutOfRange},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
|
||||
Reference in New Issue
Block a user