B Integer out of range
Sinclair ZX Spectrum
Severity: MinorWhat Does This Error Mean?
Error B on the ZX Spectrum means a number that should be a whole integer is outside the valid range. Most Spectrum commands that expect integers accept values from -65535 to 65535. Check your line numbers, GOTO/GOSUB targets, and array indices for values that are too large or too small.
Affected Models
- Sinclair ZX Spectrum 48K
- Sinclair ZX Spectrum 128K
- Spectrum+
- Spectrum +2
- Spectrum +3
- ZX Spectrum Next
- Fuse emulator
Common Causes
- GOTO or GOSUB to a line number above 9999
- POKE address or value outside the valid integer range
- Array DIM size too large for available memory
- Calculation result exceeds the integer range when an integer is required
- RUN with a line number that does not exist or is out of range
How to Fix It
-
Check the line number in GOTO, GOSUB, or RUN statements.
ZX Spectrum line numbers range from 1 to 9999. GOTO 10000 causes error B. Make sure all your line numbers and targets are within this range.
-
For POKE, check that the address is 0-65535 and the value is 0-255.
POKE 70000, 0 causes error B because 70000 exceeds the 16-bit address range. POKE 50000, 300 also causes error B because the value exceeds 255.
-
Check DIM sizes — large arrays may exceed the integer limit.
DIM A(70000) causes error B because the size exceeds the valid range. Even smaller DIM values may fail if they would use more memory than is available — but that gives error 4 (Out of memory) instead.
-
Add PRINT statements before the failing line to inspect variable values.
If a calculation result is being used where an integer is needed, PRINT the result first to see if it is out of range. This helps identify which variable has grown too large.
Frequently Asked Questions
What is the maximum line number on the ZX Spectrum?
The maximum line number is 9999. Line numbers must be positive integers from 1 to 9999. Attempting to use line 0 or line 10000 causes error B.
What is the difference between error A and error B on the Spectrum?
Error A (Invalid argument) means a value is the wrong type or mathematically impossible (like SQR of a negative). Error B (Integer out of range) means a value is numerically too large or too small for where it is being used — the type is correct but the magnitude is wrong.