Language Elements

BASIC-80

Constants

Constants are numeric values that do not change during program execution. A con- stant can be a decimal integer, hexadecimal integer, octal integer, single-precision floating-point number, or double-precision floating-point number.

Table 2-5. Numeric Data Types

Numeric Type

Range

Storage

Definition

Suffix

Examples

Required

 

 

 

 

 

 

 

 

 

 

 

Integer (decimal)

-32768 to

2 bytes

DEFINT

%

X%

 

+32767

 

 

 

9463%

Integer (hexadecimal)

Oto

2 bytes

-

H

OFF4H

 

FFFFH

 

 

 

 

Integer (octal)

Oto

2 bytes

-

0

7720

 

1777770

 

 

 

 

Single-precision floating-point

±1.2 x 10-38to

4 bytes

DEFSNG

!

X!

(7 digits precision)

± 3.4 x 1038

 

 

 

9436.5!

 

 

 

 

 

9.4365E03

Double-precision floating-point

± 2.2 x 10-308to

8 bytes

DEFDBL

#

X#

(16 digits precision)

± 1.8 x 10308

 

 

 

9436.5#

 

 

 

 

 

9.4365D03

 

 

 

 

 

 

Integer Constants

Integer constants are whole numbers in the range -32768to 32767. Each integer constant requires two bytes of memory. Because the storage requirements are lowest for integers and integer arithmetic is much faster than floating-point arithmetic, it's a good idea to use integer representation wherever possible.

Decimal Integer Constants

To identify a constant as a decimal integer constant, add the suffix 070 to the decimal integer value.

Some decimal integer constants are:

Hexadecimal Integer Constants

Hexadecimal integer constants are identified by the suffix H following the numeric value. The characters 0-9 and A-F (representing the decimal values 10-15) are used as hexadecimal digits. Each character represents 4 bits of data. The first character must be a decimal digit, so it may be necessary to add a leading o. Some hexadecimal in- teger constants are:

Hexadecimal Decimal

Equivalent

1FH31

OC76H3190

7H7

2-6

Page 16
Image 16
Intel 9800758-02 manual Decimal Integer Constants, Hexadecimal Integer Constants