beautypg.com

6 literals, 1 integer constant, Integer constant – ElmoMC Multi-Axis Motion Controller-Maestro User Manual

Page 67

background image

5.1.6

Literals

Invariant program elements are called “literals” or “constants.” The terms “literal”
and “constant” are used interchangeably here. Literals fall into four major categories:
integer,

named constant

,

floating-point

and

string literals

.

Syntax

literal :
integer-constant
named-constant
floating-constant
string-literal

5.1.6.1

Maestro

Software Manual

MAXL Program Language

MAN-MASSW (Ver. Q)

Integer Constant

Integer constants are constant data elements that have no fractional parts or
exponents. They always begin with a digit. You can specify integer constants in
decimal, octal, or hexadecimal form. They can specify signed or unsigned types and
long or short types.

Syntax

integer-constant :

decimal-constant integer

hexadecimal-constant integer

decimal-constant :

decimal-constant digit

hexadecimal-constant :

0x hexadecimal-digit

0X hexadecimal-digit

decimal-constant digit - one of the following:

0 1 2 3 4 5 6 7 8 9

hexadecimal-digit - one of the following:

0 1 2 3 4 5 6 7 8 9

a b c d e f

A B C D E F

To specify integer constants using octal or hexadecimal notation, use a prefix that
denotes the base. To specify an integer constant of a given integer type, use a suffix
that denotes the type.

To specify a decimal constant, begin the specification with a nonzero digit. For
example:

i = 157; // Decimal constant

To specify a hexadecimal constant, begin the specification with 0x or 0X (the case of
the “x” does not matter), followed by a sequence of digits in the range 0 through 9 and
a

(or A) through f (or F). Hexadecimal digits a (or A) through f (or F) represent values

in the range 10 through 15.

5-5