AppleSoft Real Variable Storage

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

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

- AppleSoft BASIC Programmer's Reference Manual

- Back to the:
- Table of Contents in Technical Note #0
- Index
- Technical Notes start page

This and all of the other Apple II Technical Notes have been converted to HTML by Aaron Heiss as a public service to the Apple II community, with permission by Apple Computer, Inc. Any and all trademarks, registered and otherwise, are properties of their owners.