Literal number construction rules

Kind of literal

Example

Legal range

Default data type

Optional type suffix

Whole numbers

777

Long

-2,147,483,648 to 2,147,483,647.

If the number falls within the range for Integer values, its data type is Integer; otherwise, its data type is Long.

% forces Integer

& forces Long

! forces Single

# forces Double

@ forces Currency

Floating point number

7.7

Double

Double decimal point.

! forces Single

# forces Double

@ forces Currency

Scientific notation

7.77E+02

Double

Double.

! forces Single

# forces Double

@ forces Currency

Binary number

&B1100101

Long

The legal range is the range for Long values. A binary integer is expressible in 32 binary digits of 0 or 1. Values >= &B100000 ... (31 zeroes) represent negative numbers. The legal prefix is &B.

% forces Integer

& forces Long

Octal number

&O1411

Long

Values >= &O40000000000 are out of range.

Values >= &O20000000000 represent negative numbers.

An octal integer is expressible in up to 11 octal digits of 0 to 7. If the number falls within the range for Integer values, its data type is Integer; otherwise, its data type is Long.

% forces Integer

& forces Long

Hexadecimal number

&H309

Long. Values = > &H80000000 represent negative numbers. Negative signs (-) are not allowed.

A hexadecimal number is expressible in 1 to 8 significant hexadecimal digits (excluding leading zeroes). If the number falls within the range for Integer values, its data type is Integer; otherwise, its data type is Long.

% forces Integer

& forces Long