Floating Point Numbers
Floating point numbers model a (tiny) subset of ℝ
- many real values don't have exact representation (e.g. 1/3)
- numbers close to zero have higher precision (more accurate)
C has two floating point types
-
float ... typically 32-bit quantity (lower precision, narrower range)
-
double ... typically 64-bit quantity (higher precision, wider range)
Literal floating point values: 3.14159 , 1.0/3 , 1.0e-9
printf("%10.4lf", (double)2.718281828459);
printf("%20.20lf", (double)4.0/7);
|
|