2^1200 gets no answer: powers past the float64 range fail inside the 4096-bit limit #16

Closed
opened 2026-09-29 07:47:29 +02:00 by clawbot · 3 comments
Collaborator

sneak, in chat on 2026-09-29:

2^1200 doesn't work on simplexcalc

2^1200 is about 1.72e361. That is past the largest float64 (about 1.8e308), but at 1201 bits it is well inside the calculator's 4096-bit limit (issue 3). So the bot should answer it exactly, and today it does not. The running bot is on next (ac72139 or later).

Definition of done:

  • The bot answers 2^1200 (and 2**1200) with the correct value, in the format it uses for other large results.
  • Tests cover 2^1200, 2^1024, 10^400, and a power that just exceeds 4096 bits, which is refused as the limit says. Where a result's size is predictable, the test checks the exact value, not just "no error".
  • Every path that computes a power is checked for the same float64 limit: whole exponents, negative exponents, fractional bases, and powers inside larger expressions. Each one found gets a test and a fix.
  • The fix is reviewed and squash-merged to next with (closes #N), and the running bot is upgraded, answering 2^1200 correctly.

Model: opus-5-5

sneak, in chat on 2026-09-29: > 2^1200 doesn't work on simplexcalc 2^1200 is about 1.72e361. That is past the largest float64 (about 1.8e308), but at 1201 bits it is well inside the calculator's 4096-bit limit (issue 3). So the bot should answer it exactly, and today it does not. The running bot is on `next` (`ac72139` or later). Definition of done: - The bot answers `2^1200` (and `2**1200`) with the correct value, in the format it uses for other large results. - Tests cover `2^1200`, `2^1024`, `10^400`, and a power that just exceeds 4096 bits, which is refused as the limit says. Where a result's size is predictable, the test checks the exact value, not just "no error". - Every path that computes a power is checked for the same float64 limit: whole exponents, negative exponents, fractional bases, and powers inside larger expressions. Each one found gets a test and a fix. - The fix is reviewed and squash-merged to `next` with (closes #N), and the running bot is upgraded, answering `2^1200` correctly. Model: opus-5-5
clawbot self-assigned this 2026-09-29 07:47:29 +02:00
Author
Collaborator

Reproduced on the running bot (next at ac72139) from a throwaway second client:

  • 2^1200, 2^1024, 10^400: "That needs a number too large or too small for me."
  • 2^1023: 8.98846567431158e+307.

Cause. The power itself is computed exactly: 2^1200 is 1201 bits, under the 4096-bit limit. The refusal happens afterwards, in format (internal/calc/calc.go): it converts every result to a float64 for display and refuses any result outside a double's normal range (about 2.2e-308 to 1.8e308), exact results included. That is stricter than the rule recorded on #3 (comment), which allows any exact result. The same step refuses exact results that are very small, such as 2^-1200.

Fix direction for the worker: an exact result is always written, in the same style as other large results (a mantissa and a decimal exponent, such as 1.7218479456305e+361), whatever its size; the normal-range rule stays for results computed in float64 only.

Model: opus-5-5

**Reproduced** on the running bot (`next` at `ac72139`) from a throwaway second client: - `2^1200`, `2^1024`, `10^400`: "That needs a number too large or too small for me." - `2^1023`: `8.98846567431158e+307`. **Cause.** The power itself is computed exactly: `2^1200` is 1201 bits, under the 4096-bit limit. The refusal happens afterwards, in `format` (`internal/calc/calc.go`): it converts every result to a float64 for display and refuses any result outside a double's normal range (about 2.2e-308 to 1.8e308), exact results included. That is stricter than the rule recorded on https://git.eeqj.de/sneak/simplexcalc/issues/3#issuecomment-105003, which allows any exact result. The same step refuses exact results that are very small, such as `2^-1200`. **Fix direction** for the worker: an exact result is always written, in the same style as other large results (a mantissa and a decimal exponent, such as `1.7218479456305e+361`), whatever its size; the normal-range rule stays for results computed in float64 only. Model: opus-5-5
Author
Collaborator

Built in #18: an exact result outside the range of a double is now written from its exact value, rounded to 17 significant digits, so 2^1200 is 1.7218479456385751e+361 and 10^400 is 1e+400. The power paths already held such results exactly; only the writing refused them. A number past the 4096-bit limit is still refused.

Model: opus-5-5

Built in https://git.eeqj.de/sneak/simplexcalc/pulls/18: an exact result outside the range of a double is now written from its exact value, rounded to 17 significant digits, so `2^1200` is `1.7218479456385751e+361` and `10^400` is `1e+400`. The power paths already held such results exactly; only the writing refused them. A number past the 4096-bit limit is still refused. Model: opus-5-5
Author
Collaborator

The running bot on sandcastle now runs next at 0b9121a with this fix. The container simplexcalc was recreated on the same simplexcalc-data volume, and its address is unchanged.

Checked from a throwaway second client: 2^1200 and 2**1200 answer 1.7218479456385751e+361, (2^1200)^0.5 answers 4.149515568880993e+180, and -7 % 3 still answers 2.

Model: opus-5-5

The running bot on sandcastle now runs `next` at `0b9121a` with this fix. The container `simplexcalc` was recreated on the same `simplexcalc-data` volume, and its address is unchanged. Checked from a throwaway second client: `2^1200` and `2**1200` answer `1.7218479456385751e+361`, `(2^1200)^0.5` answers `4.149515568880993e+180`, and `-7 % 3` still answers `2`. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/simplexcalc#16