Numeric Literals
External representation of data in the various programmable controller programming languages consists of numeric literals.There are two classes of numeric literals: integer literals and real literals. A numeric literal is defined as a decimal number or a based number.Decimal literals are represented in conventional decimal notation. Real literals are distinguished by the presence of a decimal point. An exponent indicates the integer power of ten by which the preceding number needs to be multiplied to obtain the represented value. Decimal literals and their exponents can contain a preceding sign (+ or -).Integer literals can also be represented in base 2, 8 or 16. The base is in decimal notation. For base 16, an extended set of digits consisting of letters A through F is used, with the conventional significance of decimal 10 through 15, respectively. Based numbers do not contain any leading sign (+ or -).Boolean data are represented by the keywords FALSE or TRUE.Numerical literal features and examples are shown in the table below.
Description | Examples |
Integer literals | -12 0 123 +986 |
Real literals | -12.0 0.0 0.4560 |
Real literals with exponents | -1.34E-12 or -1.34e-121.0E+6 or 1.0e+61.234E6 or 1.234e6 |
Base 2 literals | 2#11111111 (256 decimal)2#11100000 (240 decimal) |
Base 8 literals | 8#377 (256 decimal)8#340 (240 decimal) |
Base 16 literals | 16#FF o 16#ff (256 decimal)16#E0 o 16#e0 (240 decimal) |
Boolean FALSE and TRUE | FALSE TRUE |