Compaq C Language Reference Manual

Previous | Contents | Index |

The
`<errno.h>`
header file defines several macros used for error reporting.

`EDOM`

`ERANGE`

Error codes that can be stored inerrno. They expand to integral constant expressions with unique nonzero values.

`errno`

An external variable or a macro that expands to a modifiable lvalue with typeint, depending on the operating system.

Theerrnovariable is used for holding implementation-defined error codes from library routines. All error codes are positive integers. The value oferrnois 0 at program startup, but is never set to 0 by any library function. Therefore,errnoshould be set to 0 before calling a library function and then inspected afterward.

The
`<limits.h>`
and
`<float.h>`
header files define several macros that expand to various
implementation-specific limits and parameters, most of which describe
integer and floating-point properties of the hardware. See your
platform-specific *Compaq C* documentation for details.

The
`<locale.h>`
header file declares two functions and one type and defines several
macros.

A structure containing members relating to the formatting of numeric values. The structure contains the following members in any order, with values shown in the comments:

char *decimal_point; /* "." */ char *thousands_sep; /* "" */ char *grouping; /* "" */ char *int_curr_symbol; /* "" */ char *currency_symbol; /* "" */ char *mon_decimal_point; /* "" */ char *mon_thousands_sep; /* "" */ char *mon_grouping; /* "" */ char *positive_sign; /* "" */ char *negative_sign; /* "" */ char int_frac_digits; /* CHAR_MAX */ char frac_digits; /* CHAR_MAX */ char p_cs_precedes; /* CHAR_MAX */ char p_sep_by_space; /* CHAR_MAX */ char n_cs_precedes; /* CHAR_MAX */ char n_sep_by_space; /* CHAR_MAX */ char p_sign_posn; /* CHAR_MAX */ char n_sign_posn; /* CHAR_MAX */

These members are described under thelocaleconvfunction in this section.

`NULL`

`LC_ALL`

`LC_COLLATE`

`LC_CTYPE`

`LC_MONETARY`

`LC_NUMERIC`

`LC_TIME`

Expand to integral constant expressions with distinct values, and can be used as the first argument to thesetlocalefunction.

`char *setlocale(int category, const char *locale);`

Selects the appropriate portion of the program's locale as specified by thecategoryandlocalearguments. This function can be used to change or query the program's entire current locale or portions thereof.

The following values can be specified for thecategoryargument:LC_ALL---affects the program's entire locale.

LC_COLLATE---affects the behavior of thestrcollandstrxfrmfunctions.

LC_CTYPE---affects the behavior of the character-handling functions and multibyte functions.

LC_MONETARY---affects the monetary-formatting information returned by thelocaleconvfunction.

LC_NUMERIC---affects the decimal-point character for the formatted I/O functions and string-conversion functions, as well as the nonmonetary formatting information returned by thelocaleconvfunction.

LC_TIME---affects the behavior of thestrftimefunction.

The following values can be specified for thelocaleargument:

- "C"---specifies the minimal environment for C translation
- ""---specifies the use of the environment variable corresponding to
category. If this environment variable is not set, theLANGenvironment variable is used. IfLANGis not set, an error is returned.

At program startup, the equivalent of the following is executed:

setlocale(LC_ALL, "C");

Thesetlocalefunction returns one of the following:

- If a pointer to a string is specified for
localeand the selection can be honored,setlocalereturns a pointer to the string associated with the specifiedcategoryfor the new locale. If the selection cannot be honored,setlocalereturns a null pointer and the program's locale is not changed.- If a null pointer is specified for
locale,setlocalereturns a pointer to the string associated with thecategoryfor the program's current locale. The program's locale is not changed.

In either case, the returned pointer to the string is such that a subsequent call with that string value and its associated category will restore that part of the program's locale. This string must not be modified by the program, but it can be overwritten by subsequent calls tosetlocale.

`struct lconv *localeconv(void);`

Sets the components of an object with typestruct lconvwith values appropriate for formatting numeric quantities according to the rules of the current locale.

The structure members with typechar *are pointers to strings, any of which (exceptdecimal_point) can point to "", which indicates that the value has zero length or is not available in the current locale. Structure members of typecharare nonnegative numbers, any of which can beCHAR_MAXto indicate that the value is not available in the current locale. Structure members include the following:char *decimal_pointThe decimal-point character used to format nonmonetary quantities.

char *thousands_sepThe character used to separate groups of digits before the decimal point in formatted nonmonetary quantities.

char *groupingA string whose elements indicate the size of each group of digits in formatted nonmonetary quantities.

char *int_curr_symbolThe international currency symbol applicable to the current locale. The first three characters contain the alphabetic international currency symbol in accordance with those specified inISO 4217 Codes for the Representation of Currency and Funds. The fourth character (immediately preceding the null character) is the character used to separate the international currency symbol from the monetary quantity.

char *currency_symbolThe local currency symbol applicable to the current locale.

char *mon_decimal_pointThe decimal-point character used to format monetary quantities.

char *mon_thousands_sepThe character used to separate groups of digits before the decimal point in formatted monetary quantities.

char *mon_groupingA string whose elements indicate the size of each group of digits in formatted monetary quantities.

char *positive_signThe string used to indicate a nonnegative formatted monetary quantity.

char *negative_signThe string used to indicate a negative formatted monetary quantity.

char int_frac_digitsThe number of fractional digits to be displayed in internationally formatted monetary quantities.

char frac_digitsThe number of fractional digits to be displayed in formatted monetary quantities.

char p_cs_precedesSet to 1 if thecurrency_symbolprecedes the value for a nonnegative formatted monetary quantity; set to 0 if thecurrency_symbolfollows the value.

char p_sep_by_spaceSet to 1 if thecurrency_symbolis separated by a space from the value for a nonnegative formatted monetary quantity; set to 0 if there is no space.

char n_cs_precedesSet to 1 if thecurrency_symbolprecedes the value for a negative formatted monetary quantity; set to 0 if thecurrency_symbolfollows the value.

char n_sep_by_spaceSet to 1 if thecurrency_symbolis separated by a space from the value for a negative formatted monetary quantity; set to 0 if there is no space.

char p_sign_posnSet to a value indicating the positioning of thepositive_signfor a nonnegative formatted monetary quantity.

char n_sign_posnSet to a value indicating the positioning of thenegative_signfor a negative formatted monetary quantity.

The elements ofgroupingandmon_groupingare interpreted according to the following:

CHAR_MAX---no further grouping is to be performed.- 0---the previous element is to be repeatedly used for the remainder of the digits.
other---the integer value is the number of digits that comprise the current group. The next element is examined to determine the size of the next group of digits before the current group.

The value ofp_sign_posnandn_sign_posnis interpreted as follows:

- 0---parentheses surround the quantity and
currency_symbol- 1---the sign string precedes the quantity and
currency_symbol- 2---the sign string follows the quantity and
currency_symbol- 3---the sign string immediately precedes the
currency_symbol- 4---the sign string immediately follows the
currency_symbol

Thelocaleconvfunction returns a pointer to the filled in structure. The structure must not be modified by the program, but might be overwritten by subsequent calls tolocaleconvor tosetlocalewith categoriesLC_ALL,LC_MONETARY, orLC_NUMERIC.

The
`<math.h>`
header file defines types, macros, and several mathematical functions.
The functions take
`double`
arguments and return double-precision values.

The behavior of the functions in this header is defined for all representable values of their input arguments. Each function executes as if it were a single operation, without generating any externally visible exceptions.

For all functions, a *domain error* occurs if an input argument
is outside the domain over which the mathematical function is defined.
The description of each function lists any domain errors. On a domain
error, the function returns an implementation-defined value; the value
of the
`EDOM`
macro is stored in
`errno`
.

For all functions, a *range error* occurs if the result of the
function cannot be represented as a
`double`
value. If the result overflows (the magnitude of the result is so large
that it cannot be represented in an object of the specified type), the
function returns the value of the macro
`HUGE_VAL`
, with the same sign (except for the
`tan`
function) as the correct value of the function; the value of the
`ERANGE`
macro is stored in
`errno`
. If the result underflows (the magnitude of the result is so small
that it cannot be represented in an object of the specified type), the
function returns 0; whether the value of the
`ERANGE`
macro is stored in
`errno`
is implementation-defined.

Expands to a positivedoubleexpression.

Expands to a constant expression of typefloatrepresenting positive or unsigned infinity, if available; otherwise, expands to a positive constant of typefloatthat overflows at translation time.

Expands to a constant expression of typefloatrepresenting a quiet NaN.

Returns the value, in radians, of the arc cosine ofxin the range [0, pi]. A domain error occurs for arguments not in the interval [ - 1,+1].

Returns the value, in radians, of the arc sine ofxin the range [-pi/2,+pi/2]. A domain error occurs for arguments not in the interval [ - 1,+1].

Returns the value, in radians, of the arc tangent ofxin the range [-pi/2,+pi/2].

`double atan2(double y, double x);`

Returns the value, in radians, of the arc tangent ofy/x, using the signs of both arguments to determine the quadrant of the return value. The value returned is in the range [-pi,+pi]. A domain error may occur if both arguments are 0.

Returns the value, in radians, of the cosine ofx.

Returns the value, in radians, of the sine ofx.

Returns the value, in radians, of the tangent ofx.

Returns the value of the hyperbolic cosine ofx. A range error occurs if the magnitude ofxis too large.

Returns the value of the hyperbolic sine ofx. A range error occurs if the magnitude ofxis too large.

Returns the value of the hyperbolic tangent ofx.

**Exponential and Logarithmic Functions**

Returns the value of the exponential function ofx. A range error occurs if the magnitude ofxis too large.

`double frexp(double value, int *eptr);`

Breaks the floating-point numbervalueinto a normalized fraction in the interval [1/2, 1) or 0, which it returns, and an integral power of 2, which it stores in theintobject pointed to byeptr. Ifvalueis 0, both parts of the result are 0.

`double ldexp(double x, int exp);`

Multiplies a floating-point number by an integral power of 2, and returns the valuexx 2^{exp}. A range error may occur.

Returns the natural logarithm ofx. A domain error occurs if the argument is negative. A range error may occur if the argument is 0.

Returns the base-ten logarithm ofx. A domain error occurs ifxis negative. A range error may occur ifxis 0.

`double modf(double value, double *iptr);`

Breaks the argumentvalueinto integral and fractional parts, each of which has the same sign as the argument. Themodffunction returns the signed fractional part and stores the integral part as adoublein the object pointed to byiptr.

`double pow(double x, double y);`

Returns the valuex^{y}. A domain error occurs ifxis negative andyis not an integral value. A domain error occurs if the result cannot be represented whenxis 0 andyis less than or equal to 0. A range error may occur.

Returns the nonnegative square root ofx. A domain error occurs ifxis negative.

**Nearest Integer, Absolute Value, and Remainder Functions**

Returns the smallest integral value not less thanx.

Returns the absolute value of a floating-point numberx.

Returns the largest integral value not greater thanx.

`double fmod(double x, double y);`

Computes the floating-point remainder ofx/y. Thefmodfunction returns the valuex-i*y, for some integerisuch that ifyis nonzero, the result has the same sign asxand magnitude less than the magnitude ofy. The function returns 0 ifyis 0.

The
`<setjmp.h>`
header file contains declarations that provide a way to avoid the
normal function call and return sequence, typically to permit an
intermediate return from a nested function call.

Sets up the localjmp_bufbuffer and initializes it for the jump (the jump itself is performed withlongjmp.) This macro saves the program's calling environment in the environment buffer specified by theenvargument for later use by thelongjmpfunction. If the return is from a direct invocation,setjmpreturns 0. If the return is from a call tolongjmp,setjmpreturns a nonzero value.

`jmp_buf`

An array type suitable for holding the information needed to restore a calling environment.

Restores the context of the environment bufferenvthat was saved by invocation of thesetjmpfunction in the same invocation of the program. Thelongjmpfunction does not work if called from a nested signal handler; the result is undefined.

The value specified byvalueis passed fromlongjmptosetjmp. Afterlongjmpis completed, program execution continues as if the corresponding invocation ofsetjmphad just returnedvalue. Ifvalueis passed tosetjmpas 0, it is converted to 1.

Previous | Next | Contents | Index |