Compaq C Language Reference Manual

Previous | Contents | Index |

The
`<math.h>`
header file defines one macro 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.

`HUGE_VAL`

Expands to a positivedoubleexpression.

Returns the value, in radians, of the arc cosine ofxin the range [0,Pi sign]. 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 sign/2,+Pi sign/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 sign/2,+Pi sign/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 sign,+Pi sign]. 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.

The
`<signal.h>`
header file declares a type and two functions
and defines several macros for handling exception conditions that might be
reported during program execution.

The integral type of an object that can be accessed as an atomic entity, even in the presence of asynchronous interrupts.

`SIG_DFL`

`SIG_ERR`

`SIG_IGN`

Expand to constant expressions with distinct values that have a type compatible with the second argument to, and the return value of, thesignalfunction, and whose value compares unequal to the address of any declarable function.

`void (*signal(int sig, void (*handler) (int))) (int);`

Determines how subsequent signals are handled. Signals are handled in the following way:

- If the value of
handlerisSIG_DFL, default handling of that signal occurs.- If the value of
handlerisSIG_IGN, the signal is ignored.- Otherwise, when that signal occurs, a function pointed to by
handleris called with the argument of the type of signal. Such a function is called asignal handler. Valid signals include:

- SIGABRT---abnormal termination, such as from the
abortfunction- SIGFPE---arithmetic error, such as zero divide or overflow
- SIGILL---invalid function image, such as an invalid instruction
- SIGINT---interactive attention, such as an interrupt
- SIGSEGV---invalid access to storage, such as outside of memory limit
- SIGTERM---termination request sent to the program

Any other signals are operating-system dependent.

If the request can be honored, thesignalfunction returns the value ofhandlerfor the most recent call tosignalfor the specified signalsig. Otherwise, a value ofSIG_ERRis returned and an implementation-defined positive value is stored inerrno.

Sends the signalsigto the executing program. Theraisefunction returns 0 if successful and nonzero if unsuccessful.

The
`<stdarg.h>`
header file declares a type and defines three
macros for advancing through a list of function arguments of varying
number and type.

A type suitable for holding information needed by the macrosva_start,va_arg, andva_end.

To access varying arguments, the called function must declare an object (referred to asapin this section) that has the typeva_list:

va_list ap;

The objectapcan be passed as an argument to another function. If that function invokes theva_argmacro with parameterap, the value ofapin the calling function is indeterminate and is passed to theva_endmacro before any further reference toap.

`void va_start(va_list ap, parmN);`

Initializesapfor subsequent use byva_argandva_end. Theva_startmacro must be invoked before any access to the unnamed arguments.

The parameterparmNis the identifier of the rightmost parameter in the variable parameter list of the function definition. IfparmNis declared with theregisterstorage class, with a function or array type, or with a type that is not compatible with the type that results after application of the default arguments promotions, the behavior is undefined. Theva_startmacro returns no value.

*type* va_arg(va_list *ap*, *type*);

Expands to an expression that has the type and value of the next argument in the call. The parameterapis the same as theva_listapthat was initialized byva_start. Each invocation ofva_argmodifiesapso that the values of successive arguments are returned in turn. The parametertypeis a type name specified such that the type of a pointer to an object that has the specified type can be obtained by postfixing an asterisk (*) totype. The behavior is undefined if there is no actual next argument, or iftypeis not compatible with the type of the next actual argument (as promoted according to the default argument promotions).

The first invocation ofva_argafter that ofva_startreturns the value of the argument after that specified byparmN. Successive invocations return the values of the remaining arguments in turn.

Facilitates a normal return from the function whose variable argument list was referred to by the expansion ofva_startthat initialized theva_listapobject. Theva_endmacro can modifyapso that it can no longer be used (without an intervening invocation ofva_start). If there is no corresponding invocation ofva_startor ifva_endis not invoked before the return, the behavior is undefined. Theva_endmacro returns no value.

The
`<stdbool.h>`
header file defines four macros.

`bool`

Expands to_Bool.

`true`

`false`

`__bool_true_false_are_defined`

Suitable for use in#ifpreprocessing directives.

trueexpands to the integer constant 1.

falseexpands to the integer constant 0.

__bool_true_false_are_definedexpands to the integer constant 1.

The
`<stddef.h>`
header file defines several types and macros, some of which are also
defined in other header files.

A signed integral type of the result of subtracting two pointers.

An unsigned integral type of the result of thesizeofoperator.

An integral type whose range of values can represent distinct codes for all members of the largest extended character set specified among the supported locales.

`NULL`

Expands to an implementation-defined null pointer constant.

`offsetof( type, member-designator)`

Expands to an integral constant expression that has typesize_tand a value that is the offset, in bytes, to the structure member (specified bymember-designator) from the beginning of its structure (specified bytype). Themember-designatoris such that the expression&(t.evaluates to an address constant given the following:member-designator)

statictypet;

If the specified member is a bit field, the behavior is undefined.

The
`<stdio.h>`
header file declares three types, several macros, and many functions
for performing text input and output. A text stream consists of a
sequence of lines; each line ends with a new-line character.

An unsigned integral type of the result of thesizeofoperator.

An object type capable of recording all the information needed to control a data stream, including its file-position indicator, a pointer to its associated buffer (if any), anerror indicatorthat records whether a read/write error occurred, and anend-of-fileindicator that records whether the end of the file has been reached.

An object capable of recording all the information needed to uniquely specify every position within a file.

Expands to an implementation-defined null pointer constant.

Expand to integral constant expressions with distinct values, suitable for use as the third argument to thesetvbuffunction.

Expands to an integral constant expression, which is the size of the buffer used by thesetbuffunction.

Expands to a negative integral constant expression that is returned by several functions to indicate end-of-file.

Expands to an integral constant expression that is the minimum number of files that theCompaq Ccompiler for your system guarantees can be open simultaneously.

Expands to an integral constant expression that is the size needed for an array ofcharlarge enough to hold the longest file name string that theCompaq Ccompiler for your system guarantees can be opened.

Expands to an integral constant expression that is the size needed for an array ofcharlarge enough to hold a temporary file name string generated by thetmpnamfunction.

Expand to integral constant expressions with distinct values; suitable for use as the third argument to thefseekfunction.

Expands to an integral constant expression that is the minimum number of unique file names that can be generated by thetmpnamfunction.

Expressions of typepointer tothat point to theFILEFILEobjects associated, respectively, with the standard error, input, and output streams.

`int remove(const char * filename);`

Makes the file whose name is pointed to byfilenameno longer accessible by that name. Any subsequent attempt to open that file using that name will fail. Theremovefunction returns 0 if the operation succeeds, nonzero if it fails. If the file is open, the behavior of this function is implementation-defined.

`int rename(const char * old, const char *new);`

Renames the file from the name pointed to byoldto the name pointed to bynew. The file is no longer accessible by the old name. Therenamefunction returns 0 if the operation succeeds, nonzero if it fails (in which case the file, if it existed, is still known by its original name). If the new file exists beforerenameis called, the behavior of this function is implementation-defined.

Creates a temporary binary file that is automatically removed when it is closed or when program execution ends. If execution ends abnormally, whether an open temporary file is removed is implementation-dependent. The file is opened for update withwb+mode (see Table 9-1). Thetmpfilefunction returns a pointer to the stream of the file that it created. If the file cannot be created,tmpfilereturns a null pointer.

Generates a valid file name that is different than the name of an existing file. Each call totmpnam, up toTMP_MAXtimes, generates a different name. Iftmpnamis called more thanTMP_MAXtimes, the behavior is implementation-defined.

If the argument is a null pointer, thetmpnamfunction leaves its result in an internal static object and returns a pointer to that object. Subsequent calls totmpnamcan modify the same object. If the argument is not a null pointer, it is assumed to point to an array of at leastL_tmpnam chars. Thetmpnamfunction writes its result into that array and returns the argument as its value.

Previous | Next | Contents | Index |