(Actually it takes an infinite number of decimal digits as well, but that's another story).

The quickest way around this is to convert the number to fix point, which you can store in an integer:

double x = 0.0; std::cin >> x; int y = int( x * 100000 ); std::cout << "Integral part: " << y / 100000 << std::endl << "Fractional part: " << y % 100000 << "/10000" << std::endl;

This won't work with big numbers that won't fit in an integer. Multiplying by 10,000 for example makes about half the bits in the integer be used for holding the fractional part so you loose even more range. Ultimately you've got to work out what range and inaccuracy are acceptable to you and go with it.

Cheers,

Ash