Jump to content

Integer overflow: Difference between revisions

Applesoft BASIC
(Integer overflow in True BASIC)
(Applesoft BASIC)
Line 314:
1
a68g: runtime error: 1: LONG INT value out of bounds (numerical result out of range) (detected in VOID closed-clause starting at "BEGIN" in line 1).</pre>
 
=={{header|Applesoft BASIC}}==
The integer variable type is a signed 16-bit integer with a range from -32767 to 32767. When an integer variable is assigned a value less than -32767 or greater than 32767, an "?ILLEGAL QUANTITY ERROR" message is displayed and no change is made to the current value of the variable. All of the expressions for assigning the values use floating point.
<lang>A% = -(-32767-1)</lang>
{{out}}<pre>?ILLEGAL QUANTITY ERROR</pre>
<lang>A% = 20000 + 20000</lang>
{{out}}<pre>?ILLEGAL QUANTITY ERROR</pre>
<lang>A% = -32767 -32767</lang>
{{out}}<pre>?ILLEGAL QUANTITY ERROR</pre>
<lang>A% = 182 * 182</lang>
{{out}}<pre>?ILLEGAL QUANTITY ERROR</pre>
It is possible using a POKE statement to assign the value -32768 which would normally be out of range.
<lang>A% = -32767 : POKE PEEK(131) + PEEK(132) * 256, 0 : ? A%</lang>
{{out}}<pre>-32768</pre>
 
=={{header|Arturo}}==
413

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.