C++ floats and doubles
Hello.
I'm using Kdevelop(g++) on an Athlon XP system.
On my system float is 4 bytes, double 8 bytes, and long double 12 bytes. I used numeric_limits<T>::min() and numeric_limits<T>::max() to get the maximum and minimum finite value. For float MINIMUM value = 0.000000 and MAXIMUM value = 340282346638528859811704183484516925440.000000. For double and long double fo course the values are larger.
Now my question is, why can't I assign a value from within the minimum and maximum range to a variable of any of those types? Say, float X = 466385288598117041834 gives me an error.
I could do cin >> X and enter '466385288598117041834', but then cout << X returns '466385283139233644544.000000', which isn't accurate.
|