bas7qck.hlp (Table of Contents; Topic list)
Elementary Data Types - Numeric
  Data Types                                   Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
Elementary Data Types - Numeric
 
Integer Numbers
Integers are stored as 16-bit binary numbers (two bytes) ranging in value
from -32,768 to 32,767.
 
"Long" integers are stored as signed 32-bit binary numbers (four bytes)
ranging in value from -2,147,483,648 to 2,147,483,647.
 
All BASIC integers are represented as two's complement values, the most
common way of representing integers on a computer. Integers use 16 bits (2
bytes) and long integers use 32 bits (4 bytes).
 
Floating-Point Numbers
BASIC uses IEEE-format floating-point numbers rather than the Microsoft
Binary format used in earlier versions. IEEE format gives more accurate
results and makes it possible to use a math coprocessor (for example,
an 8087, 80287, or 80387).
 
Floating-point values are represented in a different format from integers.
Each floating-point value consists of three parts: the sign, the exponent,
and the mantissa.
 
In a single-precision number, the sign takes 1 bit, the exponent takes
8 bits, and the mantissa uses the remaining 23 bits and an additional
implied bit. Double-precision values occupy eight bytes or 64 bits:
1 bit for the sign, 11 bits for the exponent, and an implied bit and
52 actual bits for the mantissa.
 
Currency
A currency number is stored as an 8-byte two's complement integer, scaled
by 10,000 to give a fixed-point number with 15 digits to the left of the
decimal point and 4 digits to the right. This representation gives a range
of -922337203685477.5808 to 922337203685477.5807.
 
The currency data type is extremely useful for calculations involving
money, or for any fixed-point calculation where accuracy is more important.
Because currency numbers are stored as integers, BASIC uses integer
routines for ABS, SGN, FIX, INT, - (negation), +, and - (subtraction).