Literals

A literal is a self-defining constant that can be referred to in a program. A literal can belong to any of the RPG IV data types.

Character Literals

The following are the rules for specifying a character literal:

Hexadecimal Literals

The following are the rules for specifying a hexadecimal literal:

Numeric Literals

The following are the rules for specifying a numeric literal:

Numeric literals of the float format are specified differently. Float literals take the form:


     <mantissa>E<exponent>

Where

     <mantissa> is a literal as described above with 1 to 16 digits
     <exponent> is a literal with no decimal places, with a value
                between -308 and +308

The following lists some examples of valid float literals:


    1E1                = 10
    1.2e-1             = .12
    -1234.9E0          = -1234.9
    12e12              = 12000000000000
    +67,89E+0003       = 67890  (the comma is the decimal point)

The following lists some examples of invalid float literals:


    1.234E                          <--- no exponent
    1.2e-                           <--- no exponent
    -1234.9E+309                    <--- exponent too big
    12E-2345                        <--- exponent too small
    1.797693134862316e308           <--- value too big
    179.7693134862316E306           <--- value too big
    0.0000000001E-308               <--- value too small

Date Literals

Date literals take the form D'xx-xx-xx' where:

Time Literals

Time literals take the form T'xx:xx:xx' where:

Timestamp Literals

Timestamp literals take the form Z'yyyy-mm-dd-hh.mm.ss.mmmmmm' where:

Graphic Literals

Graphic literals take the form G'oK1K2i' where:

UCS-2 Literals

UCS-2 literals take the form U'Xxxx...Yyyy' where:

UCS-2 literals are assumed to be in the default UCS-2 CCSID of the module.



[ Top of Page | Previous Page | Next Page | Contents | Index ]