18.3.2 float
The float type is a basic data type that can indicate a 32-bit floating-point decimal number. A float-type variable or constant can have an absolute value from +3.40282347e+38 to +1.175494351e-38.
The keyword float allows you to declare and initialize a float-type variable or constant. You can use this keyword only in the DEFINE section. When you specify two or more variables after this keyword, use a comma (,) to delimit them.
You can declare a constant by using the keyword const in combination with the keyword float. The values of the constants declared in the DEFINE section can only be referenced, and cannot be changed in the MAIN or ERROR section.
- Organization of this subsection
(1) Format
DEFINE { [const] float variable_name1 [= float_constant1] [, variable_name2 [= float_constant2] ]; }
Floating-point values can include a decimal point or an exponential notation (using E or e). In the exponential part, you can specify E or e followed by an integer. A sign (+ or -) can be added to the integer. A constant of type float must consist of one or more digits, and must have a decimal point or exponent.
(2) Example of coding
DEFINE { float DefaultTimeOut = 0.01, DefaultSleep=5.0 ; // Valid float SleepMax; // Valid }
(3) Notes
-
A constant of type float can be specified only with a decimal number.
-
A float-type variable can be assigned only a value of type bool, float, or integer.
-
A float-type variable is initialized at 0 by default. In the example shown in (2) above, SleepMax is initialized at 0.
-
The number of significant digits for data of type float is 11 (including a decimal point).