Are there any lower bounds for floating point types in C? Like there are lower bounds for integral types (int being at least 16 bits)?
AS far as I know, a float always has 32 bits (at least on x86 systems). Floats, on the same architecture, always have the same size.
Maybe this helps: float.h reference (it is C++, I'm not sure if it applies to plain C as well)
float.h
contains many macros describing various properties of the floating types (including FLT_MIN
and DBL_MIN
).
The description of the requirements of the limits infloat.h
is given in the standard (C90 or C99 - 5.2.4.2.2 "Characteristics of floating types").
In particular, according to the standard any implementation must support a lower-bound of at least 1E-37
for float
or double
. But an implementation is free to do better than that (and indicate what it does in FLT_MIN
and DBL_MIN
).
See this question for information on where to get a copy of the standards documents if you need one:
Yes. float.h
contains constants such as:
FLT_EPSILON, DBL_EPSILON, LDBL_EPSILON
this is the least magnitude non-zero value which can be represented by float
, double
, and long double
representations.
FLT_MAX
and FLT_MIN
represent the extreme positive and negative numbers which can be represented for float
. Similar DBL_
and LDBL_
are available.
FLT_DIG, DBL_DIG, LDBL_DIG
are defined as the number of decimal digits precision.
You are asking for either the xxx_MIN
or the xxx_EPSILON
value.
Along these lines, here is a question wherein I posted some code which displays the internals of a 64-bit IEEE-754 floating-point number.
To be strict and grounded:
ISO/IEC 9899:TC2: (WG14/N1124m May 6, 2005):
5.2.4.2.2, Characteristics of floating types <float.h>
This Draft C99 standard (PDF) notes minimum values for floating point type precision in section 5.2.4.2.2.
(Found via Wikipedia on C99.)
Excerpts from the Standard draft (n1401.pdf)
Annex F (normative) IEC 60559 floating-point arithmetic F.1 Introduction 1 ... An implementation that defines _ _STDC_IEC_559_ _ shall conform to the specifications in this annex. ... F.2 Types 1 The C floating types match the IEC 60559 formats as follows: -- The float type matches the IEC 60559 single format. -- The double type matches the IEC 60559 double format. -- The long double type matches an IEC 60559 extended format ...
Wikipedia has an article about IEC 559 (or rather IEEE 754-1985) you might find interesting.