Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Elementary Data Types (Numeric)
◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Elementary Data Types (Numeric)
■ Visual Basic supports three kinds of numeric data types:
Keyword (Data Type) Description
═══════════════════ ═══════════════════════════════════════════════════
INTEGER, LONG Integers are stored as 16-bit binary numbers (2
(integer) bytes) ranging in value from -32,768 to 32,767.
Long integers are stored as signed 32-bit binary
numbers (4 bytes) ranging in value from
-2,147,483,648 to 2,147,483,647.
SINGLE, DOUBLE Single-precision values occupy 4 bytes, or 32 bits:
(floating-point) • 1 bit for the sign
• 8 bits for the exponent
• 23 bits for the mantissa and an implied bit
Double-precision values occupy 8 bytes, or 64 bits:
• 1 bit for the sign
• 11 bits for the exponent and an implied bit
• 52 actual bits for the mantissa
CURRENCY (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 from
-922337203685477.5808 through 922337203685477.5807.
─────────────────────────────────────────────────────────────────────────
Note: All Visual Basic integers are represented as two's complement
values, the most common way of representing integers on a computer.
■ Visual Basic uses IEEE-format floating-point numbers rather than the
Microsoft Binary format used in earlier versions of Microsoft Basic. 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.
■ The CURRENCY data type is extremely useful for calculations involving
money, or for any fixed-point calculation where accuracy is more
important. Since currency numbers are stored as integers, Visual Basic
uses integer routines for ABS, SGN, FIX, INT, - (negation), + (addition),
and - (subtraction).
See: ◄ABS Function► ◄SGN Function► ◄FIX Function► ◄INT Function►
See: ◄Basic Data Types Summary►