// double precision floating point numbers #include #include using namespace std; double x1, x2, x3, x4, x5, x6; int main() { x1 = 6.022e23; // floating point constant assigned to x1 x2 = 1.e300 * 1.e100; // overflow -> Nan, inf, etc. x3 = 1.e-300 / 1.e100; // underflow -> 0 x4 = 1. + 1e-8; // -> 1.00000001 but will be displayed as 1 x5 = (1. + 1e-8) -1.; // -> 1e-8, as expected x6 = (1. + 1e-16) -1.; // -> 0, due to machine precision error cout << x1 << ' ' << x2 << ' ' << x3 << ' '; cout << x4 << ' ' << x5 << ' ' << x6 << endl; }