robertwessel2@yahoo.com
12/10/2008 10:02:00 PM
On Dec 10, 5:00 am, Kai-Uwe Bux <jkherci...@gmx.net> wrote:
> Rolf Magnus wrote:
> > SG wrote:
>
> >> On 10 Dez., 10:44, Yoonsik Oh wrote:
> >>> The size of double type in the standard C++ is to ensure
> >>> that the 8-byte?
> >>> Or, depending on the environment are different?
>
> >> There is no guarantee. It is implementation-defined. The same is true
> >> for all other types.
>
> >> The only guarantee you have is
> >> 1 = sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)
> >> and
> >> sizeof(float) <= sizeof(double) <= sizeof(long double)
>
> > Well, there are some more guarantees. For integer types, there is a
> > minimum range, for the floating point types, a minimum precision.
>
> As far as I can tell, all guarantees about floating types are in terms of
> their precision and range [3.9.1/8]. What is guaranteed is that every float
> value is representable as a double and every double value is representable
> as a long double. However
>
> sizeof(float) <= sizeof(double) <= sizeof(long double)
>
> appears to be _not_ guaranteed. At least, I didn't find it. (Of course, an
> implementation going agains this rule would be stupidly wasteful.)
C99 6.2.5: "10: There are three real floating types, designated as
float, double, and long double. The set of values of the type float is
a subset of the set of values of the type double; the set of values of
the type double is a subset of the set of values of the type long
double."
The minimum of ten decimal digits of precision and exponent range of
-37..+37 and the needed sign implies a minimum of about 41 bits for a
double.