float, double, long double

J

JKop

Does the Standard specify any minimum range or minimum
precision for the float, double and long double. I haven't
found anything in the Standard about it.

-JKop
 
A

Andrew Koenig

Does the Standard specify any minimum range or minimum
precision for the float, double and long double. I haven't
found anything in the Standard about it.

Yes: Float must offer at least the equivalent of 6 decimal digits of
precision; double and long double must offer at least the equivalent of 10
digits.

In practice, virtually all implementations use the machine's native
floating-point types; on most machines today those offer approximately 6
digits for float and 16 digits for double. Implementations are less
consistent for long double, but double is good enough for most applications
anyway.
 
F

Fraser Ross

"Andrew Koenig"
In practice, virtually all implementations use the machine's native
floating-point types; on most machines today those offer approximately 6
digits for float and 16 digits for double.

Borland C++ documents have always stated 7 for float and 15 for double.

Fraser.
 
J

Jack Klein

Does the Standard specify any minimum range or minimum
precision for the float, double and long double. I haven't
found anything in the Standard about it.

-JKop

This is one of those cases where the C++ standard adopts the
requirements of the C standard without repeating the text.

Section 5.2.4.2 Numerical limits spells out the minimum ranges for all
integer and floating point types, and minimum precision and several
other important factors for the floating point types. An
implementation, C or C++, is required to document its implementation.

The section number is the same in both the older version of the C
standard which the C++ standard includes, and the current C standard.
 
J

JKop

Jack Klein posted:
This is one of those cases where the C++ standard adopts the
requirements of the C standard without repeating the text.

Section 5.2.4.2 Numerical limits spells out the minimum ranges for all
integer and floating point types, and minimum precision and several
other important factors for the floating point types. An
implementation, C or C++, is required to document its implementation.

The section number is the same in both the older version of the C
standard which the C++ standard includes, and the current C standard.


Great! Now all I need is the C Standard. What ever happened to self-
sufficency, self-containment?


-JKop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top