Programming in C

(Barry) #1
Standard Header Files 469

<stdbool.h>


This header file contains definitions for working with Boolean variables (type _Bool).
Define Meaning
bool Substitute name for the basic _Booldata type
true Defined as 1
false Defined as 0

<float.h>


This header file defines various limits associated with floating-point arithmetic.
Minimum magnitudes are noted at the end of each description inside parentheses. Note
that all of the definitions are not listed here.
Define Meaning
FLT_DIG Number of digits of precision for a float(6)
FLT_EPSILON Smallest value that, when added to 1.0, does not compare equal
to 1.0 (1e–5)
FLT_MAX Maximum size of a float(1e+37)
FLT_MAX_EXP Maximum size of a float(1e+37)
FLT_MIN Minimum size of a normalized float(1e–37)
Similar definitions exist for doubleand long doubletypes. Just replace the leading FLT
with DBLfor doubles, and with LDBLfor long doubles. For example,DBL_DIGgives the
number of digits of precision for a double,and LDBL_DIGgives it for a long double.
You should also note that the header file <fenv.h>is used to get information and
have more control over the floating-point environment. For example, there’s a function
called fesetroundthat allows you to specify the direction of rounding to a value as
defined in <fenv.h>:FE_TONEAREST,FE_UPWARD,FE_DOWNWARD, or FE_TOWARDZERO.You
also have the ability to clear, raise, or test floating-point exceptions, using the
feclearexcept,feraiseexcept,and fetextexceptfunctions, respectively.

<stdint.h>


This header file defines various type definitions and constants that you can use to work
with integers in a more machine-independent fashion. For example, the typedef
int32_tcan be used to declare a signed integer variable of exactly 32 bits, without hav-
ing to know the exact 32-bit integer data type on the system on which the program is
being compiled. Similarly,int_least32_tcan be used to declare an integer with a
width of at least 32 bits. Other types of typedefs allow you to select the fastest integer
representations, for example. For more information, you can take a look at the file on
your system or consult your documentation.

21 0672326663 AppB 6/10/04 2:03 PM Page 469

Free download pdf