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:
@@ -18,6 +18,7 @@ func TestReply(t *testing.T) {
|
||||
"5 * 5/2": "12.5",
|
||||
"2^10": "1024",
|
||||
"7 % 3": "1",
|
||||
"2^1200": "1.7218479456385751e+361",
|
||||
} {
|
||||
if got := bot.Reply(in); got != want {
|
||||
t.Errorf("Reply(%q) = %q, want %q", in, got, want)
|
||||
@@ -27,7 +28,7 @@ func TestReply(t *testing.T) {
|
||||
for in, want := range map[string]string{
|
||||
"hello": "I only understand arithmetic",
|
||||
"1 / 0": "I cannot divide by zero.",
|
||||
"1e400": "That needs a number too large or too small for me.",
|
||||
"1e1300": "That needs a number too large or too small for me.",
|
||||
"1e-1300": "That needs a number too large or too small for me.",
|
||||
"(-8)^0.5": "A negative number to a fractional power has no real",
|
||||
strings.Repeat("1+", calc.MaxInputLength) + "1": "That is too long for me",
|
||||
|
||||
Reference in New Issue
Block a user