-
Notifications
You must be signed in to change notification settings - Fork 2
literals
A literal is a string, integer, or floating-point constant.
A string literal enclosed in double quotes may contain any ASCII character and is case sensitive. The maximum string length is 64 characters. Strings that are longer than 64 characters must be divided up into segments and put in a list. For example, the following strings are valid:
- "This is string literal"
- "This string has an embedded newline\n"
- "21-JUL-1994"
By convention, when the value of a literal begins with a "%", the value will be tested false. For example:
STATUS = "%ERROR";
if ( !STATUS ) {
put ( "Error occurred" );
exit();
}
_
will print "Error occurred".
An integer literal comes in three formats: decimal, hexadecimal, and octal. Decimal literals are, for example:
- 0
- -1234
- 2147483647
- 10000000000000000000000000000000000
Note that the last example is outside the range represented by the integer data type.
A literal starting with zero followed by _x _(0x) is a hexadecimal (base 16) number. For example:
- 0x0
- 0xbdf
- 0x1234
A literal starting with zero followed by o (0o) is an octal (base 8) number. For example:
- 0o0
- 0o1234
- 0o77
A floating-point literal contains a decimal point and an optional exponent value. Valid floating-point literals are:
- 1.23
- 0.
- -1.e10
- 1.23e-12