There are two implementation-defined headers that contain this information for your system. They are called limits.h and float.h. The header limits defines constants for the size of integral types and float.h contains constants related to floating point arithmetic.
For example, the max and min of int can be found in the macros INT_MAX and INT_MIN. And long int can be found in LONG_MAX and LONG_MIN. For the floating point values the macro FLT_MAX gives the maximum floating point number and FLT_MIN gives the minimum normalized floating point number. There are other macros defined in both of these.
Here are more float macros: http://www.fortran-2000.com/ArnaudRecipes/Cstd/2.4.html
See Ya
Butch
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"There are two implementation-defined headers that contain this information for your system"
In 4.9.9.2 I do not see FLT_MAX. As for the int's what happens if say I use Athlon64/Win64? Then it would seem limits.h probably is a compiler limit rather than a processor / platform limit?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-04-04
FLT_MAX is defined in float.h
>As for the int's what happens if say I use Athlon64/Win64? Then it would seem limits.h probably is a compiler limit rather than a processor / platform limit?
A 32bit compiler will have 32bit integers to match the platform for which it was designed. If you use a 32bit compiler on a 64bit platform, that is your decision. Just as using a DOS compiler on a Win32 platform will only have 16 bit integers.
As it happens the sizeof int is likely to be 32bits even on a 64bit platform, but long and long long will both be 64bits. In many cases this will prevent code from breaking and make porting to 64bit platforms easier. The AMD64 ABI specifies that C compilers should use 32bits for the int data type: http://www.x86-64.org/documentation/abi.pdf
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The limits defined in the headers limits.h and float.h are the C compiler's limits, not the processors, as you guessed. That is, the limits that were defined when the C compiler was designed. Different implemenations of C (like GNU C, Borland C, Code Warrior C) can define different sizes for these types. The only thing that the C Standards committee has done is define a minimum size that these must be, but anyone who wants to design there own C compiler is free to make these larger if they want.
You should be able to see the value of any simply by including the macro in a printf statement.
See Ya
Butch
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"There are two implementation-defined headers that contain this information for your system"
Clifford, so we agree the above statement is wrong. The last word should be compiler. It's a compiler limitation rather than platform. Whether it's my decision is just clouding the original question.
I see you are both correct about FLT_MAX. It is more apparent when one knows that two float.h headers come with 4.9.9.2
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-04-04
I am not disputing that statement at all - the term 'system' could mean anything, it may be ambiguous, but it would be pedantic to say it was wrong.
With respect to <float.h>, there are indeed two float.h files, but they are effectively a single file, split into two - a GCC generic part, and a MinGW specific part.
The generic part includes the GCC preprocessor extension statement: #include_next<float.h>. This means include float.h, but only using the remaining include search paths not yet procesed. By placing C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include in the include search paths after C:\Dev-Cpp\include, the files are combined in the correct order. This is knows as a wrapper header.
"Just as using a DOS compiler on a Win32 platform will only have 16 bit integers."
I understand what you say, but just to avoid anyone's misconceptions, even under plain DOS (without Windows), if the compiler is prepared for using a 32 bit DOS extender, it will (most likely) have 32 bit int's.
RaX
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-04-04
Of course, that would be a 32bit compiler that generates applications that work from DOS - they are still 32 bit applications.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The statement "There are two implementation-defined headers that contain this information for your system" is correct. I read my copy of K&R "The C Programming Language" before I made this statement. But Clifford is still correct in that it is ambiguous.
See Ya
Butch
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It begs the question: Why be ambiguous when ones vocabulary is not limited? Give up on K&R being the defining authority. ANSI has taken over :P
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-04-05
while it is true that K&R first edition was the once official definition of the language, the second edition is not. The second edition does describe ANSI C (at least C89), and as such is an authoratitive distillation of the standard.
That said, the ANSI standard has been superseded by the ISO standard. This is not a significant change in teh standard, simply that the standards authority has changed.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What is the minimum/maximum number that a float can hold?
Depends on your system. Find the maximum with something like this:
include <limits>
std::cout << std::numeric_limits<float>::max();
The min() function returns the smallest value near zero, i.e. the smallest representable fraction.
qWake
Hi Everyone:
There are two implementation-defined headers that contain this information for your system. They are called limits.h and float.h. The header limits defines constants for the size of integral types and float.h contains constants related to floating point arithmetic.
For example, the max and min of int can be found in the macros INT_MAX and INT_MIN. And long int can be found in LONG_MAX and LONG_MIN. For the floating point values the macro FLT_MAX gives the maximum floating point number and FLT_MIN gives the minimum normalized floating point number. There are other macros defined in both of these.
Here are more float macros:
http://www.fortran-2000.com/ArnaudRecipes/Cstd/2.4.html
See Ya
Butch
"There are two implementation-defined headers that contain this information for your system"
In 4.9.9.2 I do not see FLT_MAX. As for the int's what happens if say I use Athlon64/Win64? Then it would seem limits.h probably is a compiler limit rather than a processor / platform limit?
FLT_MAX is defined in float.h
>As for the int's what happens if say I use Athlon64/Win64? Then it would seem limits.h probably is a compiler limit rather than a processor / platform limit?
A 32bit compiler will have 32bit integers to match the platform for which it was designed. If you use a 32bit compiler on a 64bit platform, that is your decision. Just as using a DOS compiler on a Win32 platform will only have 16 bit integers.
As it happens the sizeof int is likely to be 32bits even on a 64bit platform, but long and long long will both be 64bits. In many cases this will prevent code from breaking and make porting to 64bit platforms easier. The AMD64 ABI specifies that C compilers should use 32bits for the int data type: http://www.x86-64.org/documentation/abi.pdf
Clifford
Hi Everyone:
The limits defined in the headers limits.h and float.h are the C compiler's limits, not the processors, as you guessed. That is, the limits that were defined when the C compiler was designed. Different implemenations of C (like GNU C, Borland C, Code Warrior C) can define different sizes for these types. The only thing that the C Standards committee has done is define a minimum size that these must be, but anyone who wants to design there own C compiler is free to make these larger if they want.
You should be able to see the value of any simply by including the macro in a printf statement.
See Ya
Butch
"There are two implementation-defined headers that contain this information for your system"
Clifford, so we agree the above statement is wrong. The last word should be compiler. It's a compiler limitation rather than platform. Whether it's my decision is just clouding the original question.
I see you are both correct about FLT_MAX. It is more apparent when one knows that two float.h headers come with 4.9.9.2
I am not disputing that statement at all - the term 'system' could mean anything, it may be ambiguous, but it would be pedantic to say it was wrong.
With respect to <float.h>, there are indeed two float.h files, but they are effectively a single file, split into two - a GCC generic part, and a MinGW specific part.
The generic part includes the GCC preprocessor extension statement: #include_next<float.h>. This means include float.h, but only using the remaining include search paths not yet procesed. By placing C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include in the include search paths after C:\Dev-Cpp\include, the files are combined in the correct order. This is knows as a wrapper header.
See: http://gcc.gnu.org/onlinedocs/gcc-3.4.3/cpp/Wrapper-Headers.html#index-_0023include_005fnext-37
Clifford
"Just as using a DOS compiler on a Win32 platform will only have 16 bit integers."
I understand what you say, but just to avoid anyone's misconceptions, even under plain DOS (without Windows), if the compiler is prepared for using a 32 bit DOS extender, it will (most likely) have 32 bit int's.
RaX
Of course, that would be a 32bit compiler that generates applications that work from DOS - they are still 32 bit applications.
Cliff, can you go into a bar and order a beer without telling the bartender where the hops were grown or what grain and yeast were used?
Bramling Cross hops, grown in Kent, England; Maris Otter Pale Malt; Munton's Gold yeast.
;-)
Hi Everyone:
The statement "There are two implementation-defined headers that contain this information for your system" is correct. I read my copy of K&R "The C Programming Language" before I made this statement. But Clifford is still correct in that it is ambiguous.
See Ya
Butch
It begs the question: Why be ambiguous when ones vocabulary is not limited? Give up on K&R being the defining authority. ANSI has taken over :P
while it is true that K&R first edition was the once official definition of the language, the second edition is not. The second edition does describe ANSI C (at least C89), and as such is an authoratitive distillation of the standard.
That said, the ANSI standard has been superseded by the ISO standard. This is not a significant change in teh standard, simply that the standards authority has changed.
Clifford