Float Limit (Large)


Program Listing

FloatLimitLarge.cpp

/************************************************************************
*                                                                       *
*   Program:    Float Limit Large                                       *
*                                                                       *
************************************************************************/

#include <iostream>
#include <string>

using namespace std;

int main() {

//  Print some large floats

    float x = 1.0;
    cout << x << endl;      // Print 1
    x = 10 * x;
    cout << x << endl;      // Print 10
    x = 10 * x;
    cout << x << endl;      // Print 100
    x = 10 * x;
    cout << x << endl;      // Print 1000
    x = 10 * x;
    cout << x << endl;      // Print 10000

//  Print some really large floats

    x = 1.0e10;
    cout << x << endl;      // Print 10^10
    x = 1.0e10 * x;
    cout << x << endl;      // Print 10^20
    x = 1.0e10 * x;
    cout << x << endl;      // Print 10^30
    x = 1.0e10 * x;
    cout << x << endl;      // Print 10^40
    x = 1.0e10 * x;
    cout << x << endl;      // Print 10^50

    return 0;
}

Sample Run

1
10
100
1000
10000
1e+10
1e+20
1e+30
inf
inf



Return to Lectures page


e-mail me at robbk@hsc.edu

This page was last modified on Tue Dec 7 16:04:22 1999 .

URL: http://people.hsc.edu/faculty-staff/robbk/Coms261/Examples/FloatLimitLarge.html

Return to Coms 261 home page