?OVERFLOW ERROR
Commodore Commodore 64
Severity: MinorWhat Does This Error Mean?
?OVERFLOW ERROR means a calculation produced a number too large for BASIC V2 to handle. The C64 can handle numbers up to approximately 1.7 x 10^38. Break large calculations into smaller steps or use logarithms.
Affected Models
- Commodore 64
- Commodore 64C
- Commodore 128 (C64 mode)
- VICE emulator (C64)
Common Causes
- Multiplication or exponentiation producing a result beyond 1.7E+38
- Runaway loop that keeps multiplying without a limit check
- Factorial calculation for large numbers
- Division by a very small number producing a very large result
How to Fix It
-
Identify which line causes the overflow.
BASIC reports the line number. Type LIST followed by that number to see the calculation.
-
Add bounds checking before the calculation.
Before A = A * B, add: IF A > 1E30 THEN PRINT "NUMBER TOO LARGE" : STOP
-
Break the calculation into smaller steps.
Instead of A = B * C * D, compute X = B * C first, check it, then A = X * D.
-
Use LOG() for very large number operations.
LOG converts to logarithmic scale where multiplication becomes addition. This avoids overflow for calculations involving very large numbers.
Frequently Asked Questions
What is the largest number the C64 can handle?
Approximately 1.70141183 x 10^38. This is the limit of the floating-point format used by Commodore BASIC V2.
What happens with very small numbers?
Numbers smaller than approximately 2.94 x 10^-39 are silently rounded to zero. This is called underflow and does not produce an error.