Answer exact results past the range of a double, such as 2^1200 (closes #16)
check / check (push) Successful in 1m18s
check / check (push) Successful in 1m18s
`2^1200` was refused although the calculator computed it exactly: writing a result went through a float64 and refused anything outside a double's range. An exact result under the 4096-bit limit is now written from its exact value, rounded to 17 significant digits past that range, and a fractional power of such a number is computed by first bringing its base into range with square roots taken from the exact value. Results computed in float64 must still be normal doubles; past the 4096-bit limit is still refused. Disclosures: `1e-310` is answered again, reversing a call made in PR 11; a fractional power carries `math.Pow`'s rounding, which for a large base can reach the last digits shown. Model: opus-5-5
This commit was merged in pull request #18.
This commit is contained in:
@@ -426,16 +426,23 @@ container.
|
||||
refused, exact powers are capped, and every number is held as a
|
||||
fraction, whole numbers too, under the 4096-bit limit below, so a
|
||||
message cannot make the bot do unbounded work. Whole numbers below
|
||||
10<sup>21</sup> are written exactly; other results in the shortest
|
||||
form that reads back as the same double, in exponent notation from
|
||||
10<sup>21</sup> up and below 10<sup>-6</sup>. Refused as too large or
|
||||
too small: any number whose numerator or denominator reaches 4096
|
||||
bits, wherever it appears, as `go/constant` rounds a fraction that
|
||||
grows that large (`1e-1300 + 1`); a power computed as a double whose
|
||||
base or result is outside the normal range of a double, about 2.2e-308
|
||||
to 1.8e308 in magnitude, where a double keeps all its digits
|
||||
(`1e-400^0.5`); and a result other than zero outside that range, as it
|
||||
is written through a double (`1e400`, `2^-1400`).
|
||||
10<sup>21</sup> are written exactly. Other results inside the normal
|
||||
range of a double, about 2.2e-308 to 1.8e308 in magnitude, where a
|
||||
double keeps all its digits, are written in the shortest form that
|
||||
reads back as the same double, in exponent notation from
|
||||
10<sup>21</sup> up and below 10<sup>-6</sup>. Results outside that
|
||||
range are written from their exact value in exponent notation, rounded
|
||||
to 17 significant digits, the most the shortest form of a double
|
||||
takes, with trailing zeros dropped: `2^1200` is
|
||||
`1.7218479456385751e+361`, `10^400` is `1e+400` and `2^-1074` is
|
||||
`4.9406564584124654e-324`. Refused as too large or too small: any
|
||||
number whose numerator or denominator reaches 4096 bits, wherever it
|
||||
appears, as `go/constant` rounds a fraction that grows that large
|
||||
(`2^4095`, `1e-1300 + 1`); and a power computed as a double whose
|
||||
result is outside the normal range of a double (`2^1500.5`). The base
|
||||
of such a power may be outside that range: square roots taken from its
|
||||
exact value bring it inside first, so `(2^1200)^0.5` is
|
||||
`4.149515568880993e+180` and `1e-400^0.5` is `1e-200`.
|
||||
- **Failure is an exit.** If the chat client exits or the connection to
|
||||
it drops, the bot exits with an error and the container's restart
|
||||
policy starts both again. `SIGTERM` stops the bot, which stops the
|
||||
|
||||
Reference in New Issue
Block a user