HP 3000 Manuals

Integer Constants [ HP C/iX Reference Manual ] MPE/iX 5.0 Documentation


HP C/iX Reference Manual

Integer Constants 

Integer constants represent integer values.

Syntax 

     integer-constant ::=
             decimal-constant [integer-suffix] 
             octal-constant [integer-suffix] 
             hexadecimal-constant [integer-suffix] 

     decimal-constant ::=
             nonzero-digit 
             decimal-constant digit 

     octal-constant ::=
             0
             octal-constant octal-digit 

     hexadecimal-constant ::=
             0x hexadecimal-digit 
             0X hexadecimal-digit 
             hexadecimal-constant hexadecimal-digit 

     nonzero-digit ::= any character from the set
             1  2  3  4  5  6  7  8  9

     octal-digit ::= any character from the set
             0  1  2  3  4  5  6  7

     hexadecimal-digit ::= any character from the set
             0  1  2  3  4  5  6  7  8  9
             a  b  c  d  e  f
             A  B  C  D  E  F

     integer-suffix ::=
             unsigned-suffix [long-sufix] 
             long-suffix [unsigned-suffix] 

     unsigned-suffix ::= any character from the set
             u  U

     long-suffix ::= any character from the set
             l  L


NOTE The u and U suffixes are available only in ANSI mode.
Description An integer constant begins with a digit, but has no period or exponent part. It may have a prefix that specifies its base (decimal, octal, or hexadecimal) and suffix that specifies its type. The size and type of integer constants are described in Chapter 9, HP C/iX Implementation Topics. Octal constants begin with a zero and can contain only octal digits. Several examples of octal constants are: 077 01L 01234567 0222l Hexadecimal constants begin with either 0x or 0X. The case of the x character makes no difference to the constant's value. The following are examples of hexadecimal constants: 0xACE 0XbAf 0x12L The suffix L or l stands for long. The suffix U or u stands for unsigned. Both can be used on all three types of integer constants (decimal, octal, and hexadecimal). The type of an integer constant is the first of the corresponding list in which its value can be represented, as described below. * Unsuffixed decimal: int, unsigned long int. * Unsuffixed octal or hexadecimal: int, unsigned int. * Suffixed by the letter u or U: unsigned int. * Suffixed by the letter l or L: long int, unsigned long int. * Suffixed by both the letters u or U and l or L: unsigned long int. Examples 0xFFFFu unsigned int, hexadecimal 4196L signed long int, decimal 0X89ab signed int, hexadecimal 047L signed long int, octal 64U unsigned int, decimal 15 signed int, decimal 15L signed long int, decimal 15U unsigned int, decimal 15UL unsigned long int, decimal 15LU unsigned long int, decimal 0125 signed int, octal


MPE/iX 5.0 Documentation