A constant is a numerical value that does not change during program execution. In writing R3 instructions, the use of constants is allowed.
There are some constants that are specific to the language and cannot be changed by the user.
Predefined mathematical constants
Keyword |
Numerical Value |
Meaning |
---|---|---|
K_E |
2.718281828459045 |
Euler constant |
K_PI |
3.141592653589793 |
PI |
K_PIMEZZI |
1.570796326794896 |
PI half |
K_PI_2 |
1.570796326794896 |
PI half |
K_1_PI |
0.318309886183790 |
One divided PI |
K_DUEPI |
6.283185307179586 |
Two PI |
K_2PI |
6.283185307179586 |
Two PI |
K_EPSILON |
1e-6 |
Decision threshold for comparisons between reals |
K_MAXFLOAT |
3.37e+38 |
Largest constant representable in a float |
K_MINFLOAT |
8.43e-37 |
Smallest constant representable in a float |
K_MAXREAL |
1.797693e+308 |
Largest constant representable in a double |
K_MINREAL |
2.225074e-308 |
Smallest constant representable in a double |
User-definable constants
The types of constants that the programmer can define are:
Integer constants
They can be any integer between -2147483648 and +2147483647.
Integer constants can be represented in decimal or hexadecimal base.
To identify an hexadecimal number it will be necessary to add the letter "H" to the end of the number, or prefix the number with "0x".
Hexadecimal numbers must always begin by numeric digit (prefix the 0 if necessary). Hexadecimal numbers are represented in two-complement on 8 digits, and the minus sign is therefore not allowed.
Examples
Example decimal constants:
; Decimal constants 10 -20 |
Example hexadecimal constants:
0XA ; Decimal value 10 0AH ; Decimal value 10 10H ; Decimal value 16 0FFH ; Decimal value 255 FFFFFFH ; Decimal value -1 0XFFFFFF ; Decimal value -1 |
Real constants
They can be any real number between -1.79 E 308 and 1.79 E 308.
The smallest entity that can be represented is, in absolute value 2.22 E -308.
The significant digits are at least 15.
The syntax of the representation of a real number is as follows: si.d
Parameter |
Meaning |
---|---|
s |
sign of the number (optional) |
i |
integer part of the number |
. |
decimal separator (optional) |
d |
decimal part of the number (optional) |
The syntax of the exponential representation is as follows: si.dEse
Parameter |
Meaning |
---|---|
s |
sign of the number (optional) |
i |
integer part of mantissa |
. |
decimal separator (optional) |
d |
decimal part of the mantissa (optional) |
E |
exponential format identifier (in base 10) |
s |
sign of the exponent (optional) |
e |
exponent |
Examples
Example real constants:
10 10.51 1452.7 1.4527E3 -12.4567E-4 |
Sting constants
String constants can be any sequence of characters between double quotes " ".
NOTE: To use the double-quote (") character within a string constant the syntax to use is \" . The maximum length is 127 net characters.
Examples
Example usage:
; String constant example "this is a string" "the doublet character \" is contained in this string " |