Hello, [EMAIL PROTECTED] wrote:
> I am using gcc version 3.4.2 (mingw-special) version compiler and the > following code is not giving expected output. > #include <iostream> using namespace std; int main() { double d; cin >> d; cout << d; return 0; } > > It gives out a garbage value int output when I give 2.22507e-308 as > input value to read. As others have said, this seems to be an overflow. Try do increase the exponent to find the minimal one producing sensible results. If a value near to 1e-38 seems to be the smallest sensible value, then internally something is converted to or from float (single precision) this would not be a bug, I think the only requirement for double is to be at least as accurate as float. But the machines, where mingw runs on, usually support double, so it would be a problem. Try double d = 1.0 for (int i = 0; i < 400; i++) std::cout<< d/=10.0; On my system 2.22507e-308 is no problem with your app, values down to 2.22507e-323 produce sensible results, but with decreasing accuracy, and 2.22507e-324 produces zero. All inputs down from there produce garbage, i.e. underruns. Probably my system supports denormalized presentations of double, i.e. smaller values than the minimal one with full precision, which is 2.22507e-308. This explains the 15 digits extra, which are the number of digits the mantissa can hold on my system. Look at std::numerical_limits<double>::min() etc. Bernd Strieder _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus