For floating point, or real, numbers, two types are available, as shown in Table 2.3. Note that integer and real data types are guaranteed to take on the sizes in the preceding tables regardless of the hardware platform on which the program runs.
When a literal value is assigned to a float variable, the value must be suffixed by an f or
F, for example
float fvar = 6.2f;
The f indicates that 6.2 is a number of type float. By default, literal floating point numbers are of type double, but we can use a d or D suffix. So both the following are valid:
double dvar = 6.234;
double dvar = 6.234d;
When a literal value is assigned to a float variable, the value must be suffixed by an f or
F, for example
float fvar = 6.2f;
The f indicates that 6.2 is a number of type float. By default, literal floating point numbers are of type double, but we can use a d or D suffix. So both the following are valid:
double dvar = 6.234;
double dvar = 6.234d;
No comments:
Post a Comment