Float Limit (Small)

Program Listing

• This program pushes the limit of floats by attempting to print ever smaller floats until something goes wrong.

FloatLimitSmall.cpp

 ```/************************************************************************ * * * Program: Float Limit Small * * * ************************************************************************/ #include #include using namespace std; int main() { // Print some small floats float x = 0.1; cout << x << endl; // Print 0.1 x = x * 0.1; cout << x << endl; // Print 0.01 x = x * 0.1; cout << x << endl; // Print 0.001 x = x * 0.1; cout << x << endl; // Print 0.0001 x = x * 0.1; cout << x << endl; // Print 0.00001 // Print some really small floats x = 1.0e-10; cout << x << endl; // Print 10^(-10) x = x * 1.0e-10; cout << x << endl; // Print 10^(-20) x = x * 1.0e-10; cout << x << endl; // Print 10^(-30) x = x * 1.0e-10; cout << x << endl; // Print 10^(-40) x = x * 1.0e-10; cout << x << endl; // Print 10^(-50) x = x * 1.0e-10; cout << x << endl; // Print 10^(-60) return 0; }```

Sample Run

 ```0.1 0.01 0.001 1e-04 1e-05 1e-10 1e-20 1e-30 9.99995e-41 0 0 ```