Constants provide a way to define a variable
which cannot be modified by any other part in the code.
Constants can be defined by placing the keyword
in front of any variable declaration. If the keyword
volatile is placed after
then this allows external routines to modify the variable (such
as hardware devices). This also forces the compiler to retrieve
the value of the variable each time it is referenced rather than
possibly optimizing it in a register.
Constant numbers can be defined in the following way:
0x hexadecimal digits...
Where hexadecimal digits is any digit or any
Any number where the first number is not zero.
Any number where the first number must be zero.
A fractional number, optionally followed by either
E then the
The number may be suffixed by:
Causes the number to be an unsigned long integer.
If the number is a floating-point number, then it is a
long double, otherwise it is an unsigned long integer.
Causes the number to be a floating-point number.
const float PI=3.141;
Causes the variable PI to be created with value 3.141. Any
subsequent attempts to write to PI are not allowed.
const int joe=0xFFFF;
Causes joe to be created with the value of 65535 decimal.
const float penny=7.4e5;
Causes penny to be created with the value of 740000.000000.