Apple II
Technical Notes
_____________________________________________________________________________
Developer Technical Support
Apple II Miscellaneous
#9: AppleSoft Real Variable Storage
Revised by: Pete McDonald November 1988
Written by: Cameron Birse December 1986
This Technical Note discusses real variable storage in AppleSoft BASIC.
_____________________________________________________________________________
In AppleSoft BASIC, real variables (non-array) are stored sequentially
starting at the address pointed to by locations $69 and $6A. The first two
bytes are the name of the variable, the third is the exponent, and the fourth
through seventh are the mantissa.
Exponent The top bit of this byte is the sign of the exponent. This sign
bit is the opposite of normal sign bits, since zero is negative
and one is positive. The remainder of the byte minus one is the
value of the exponent (i.e., 84 is a positive exponent of 3).
Mantissa The mantissa is a binary fraction with the first bit being the
sign bit (normal this time with zero being positive and one
negative), and the remaining bits are fractional values starting
with .5, .25, .125, etc.
The equation which follows is: 2^(Exponent-1) * 1.Mantissa
Examples
A = 3 (real variable equal to 3)
The seven bytes look like: 41 00 Variable name = A
82 Exponent = 1
40 00 00 00 Mantissa = .5
which works out as: 2^1 * 1.5 = 3
B = 5 (real variable equal to 5)
The seven bytes look like: 42 00 Variable name = B
83 Exponent = 2
20 00 00 00 Mantissa = .25
which works out as: 2^2 * 1.25 = 5
Further Reference
o AppleSoft BASIC Programmer's Reference Manual