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)?
- 
                    1Hi Geekhero, welcome to StackOverflow. If you wish to reply in the comments, at the bottom of your own question there is a grey text link which reads "add comment." This is how people communicate with each other here. – Heath Hunnicutt Nov 11 '09 at 09:17
- 
                    do you want to map floats to fewer bits (less accuracy) ? – Nick Dandoulakis Nov 11 '09 at 09:19
- 
                    1You cannot comment with only 1 reputation point. – ndim Nov 11 '09 at 09:19
- 
                    2@ndim: Yes you can. "you can always comment on your questions and answers, and any answers to questions you've asked, even with 1 rep." (faq) – fresskoma Nov 11 '09 at 16:35
7 Answers
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.
 
    
    - 1
- 1
 
    
    - 18,667
- 3
- 39
- 62
- 
                    1That wasn't the question. Geekhero is asking for the bounds which the language puts on those constants, not how to get the values in a particular implementation. – Steve Jessop Nov 11 '09 at 16:35
- 
                    Surely you realize the bounds are not defined by the language standard, but by the implementation? And that most implementations adhere to IEEE-754? But the OP can't count on that because the answer will vary by platform? – Heath Hunnicutt Nov 11 '09 at 17:34
- 
                    1The language standard defines bounds *on the bounds*. The OP says "like ... int being at least 16 bits". Similarly, float represents at least 6 decimal places. If it represents more, then FLT_DIG will be greater than 6, but it must not be less. – Steve Jessop Nov 11 '09 at 18:14
- 
                    Steve, your point of view might be a better answer to the OP's question. You should add an answer. – Heath Hunnicutt Nov 11 '09 at 18:40
- 
                    Unless you would like to community wiki this answer I wrote, I'd be glad to change it, but usually when I transform to wiki, nobody participates in the edits but me. – Heath Hunnicutt Nov 11 '09 at 18:41
- 
                    Roman, ndim, and Konamiman's answers are to the question that I think was intended: they all point to lists of the minimum values required for the constants you mention (although they each chose different references, so I suppose there's something to be said for one answer to rule them all...) – Steve Jessop Nov 11 '09 at 19:03
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>
 
    
    - 12,800
- 7
- 74
- 110
- 
                    Also, Annex F of that draft proposes that floats should adhere to IEEE-754, but is not specific about the size of long double. – Heath Hunnicutt Nov 11 '09 at 17:48
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:
 
    
    - 1
- 1
 
    
    - 333,147
- 50
- 533
- 760
- 
                    1That wasn't the question. Geekhero is asking for the bounds which the language puts on those constants, not how to get the values in a particular implementation – Steve Jessop Nov 11 '09 at 16:35
- 
                    The question can probably be reasonably interpreted either way. Regardless, a better answer would discuss both areas (they're still kind of the same answer - the documentation for `float.h` talks about the required limits for an implementation, the contents of a particular `float.h` describe a particular implementation's limits. I've updated the answer to try to better cover both angles. – Michael Burr Nov 11 '09 at 17:34
Maybe this helps: float.h reference (it is C++, I'm not sure if it applies to plain C as well)
 
    
    - 49,681
- 17
- 108
- 138
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.)
 
    
    - 35,870
- 12
- 47
- 57
A useful reference here is What Every Computer Scientist Should Know About Floating-Point Arithmetic.
The nature of a floating point number — its size, precision, limits — is really defined by the hardware, rather than the programming language. A single-precision float on an x86 is the same in C, C#, Java, and any other practical programming language. (The exception is esoteric programming languages that implement odd widths of floating point number in software.)
 
    
    - 40,496
- 12
- 101
- 170
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.
 
    
    - 106,608
- 13
- 126
- 198
