United States |
|
|
||
9.16.1 Real-Type DeterminationUse of the macro invokes a function whose generic parameters have the corresponding real type determined as follows:
9.16.2 Unsuffixed Functions in (<math.h>) and (<complex.h>) with the Same NameFor each unsuffixed function in <math.h> for which there is a function in <complex.h> with the same name except for a c prefix, the corresponding type-generic macro (for both functions) has the same name as the function in <math.h> . The corresponding type-generic macro for fabs and cabs is fabs . These functions are:
If at least one argument for a generic parameter is complex, then use
of the macro invokes a complex function; otherwise, use of the macro
invokes a real function.
For each unsuffixed function in <math.h> without a c-prefixed counterpart in <complex.h> , the corresponding type-generic macro has the same name as the function. These type-generic macros are:
If all arguments for generic parameters are real, then use of the macro
invokes a real function; otherwise, use of the macro results in
undefined behavior.
For each unsuffixed function in <complex.h> that is not a c-prefixed counterpart to a function in <math.h> , the corresponding type-generic macro has the same name as the function:
Use of the macro with any real or complex argument invokes a complex
function.
Consider the following declarations:
Given these declarations, functions invoked by use of type-generic macros are as follows:
9.16.6 Imaginary ArgumentsType-generic macros that accept complex arguments also accept imaginary arguments. If an argument is imaginary, the macro expands to an expression whose type is real, imaginary, or complex, as appropriate for the particular function: if the argument is imaginary, then the types of cos , cosh , fabs , carg , cimag , and creal are real; the types of sin , tan , sinh , tanh , asin , atan , asinh , and atanh are imaginary; and the types of the others are complex. Given an imaginary argument, each of the type-generic macros cos , sin , tan , cosh , sinh , tanh , asin , atan , asinh , atanh is specified by a formula in terms of real functions:
9.17 Date and Time (<time.h>)The <time.h> header file defines two macros, and declares four types and several functions for manipulating time and date information. Some functions process local time, which may differ from calendar time because of time zone. An unsigned integral type of the result of the sizeof operator.
Arithmetic types capable of representing times. Holds the components of a calendar time, called the broken-down time. The structure contains the following members: Expands to an implementation-defined null pointer constant. The number per second of the value returned by the clock function. char *asctime(const struct tm *timeptr); Converts a broken-down time in the structure pointed to by timeptr into a 26-character string in the form of this example: char *ctime(const time_t *timer); Converts the calendar time pointed to by timer to local time in a string of the form generated by the asctime function. A pointer to the string is returned. The ctime function is equivalent to the following: struct tm *gmtime(const time_t *timer); Converts the calendar time pointed to by timer into a broken-down time expressed as Coordinated Universal Time (UTC). The gmtime function returns a pointer to the broken-down time, or a null pointer if UTC is not available. struct tm *localtime(const time_t *timer); Converts the calendar time pointed to by timer into a broken-down time expressed as local time. The localtime function returns a pointer to the broken-down time. size_t strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr); Places characters into the array pointed to by s as controlled by the string pointed to by format. The format string consists of zero or more conversion specifiers and ordinary multibyte characters. All ordinary multibyte characters (including the terminating null character) are copied unchanged into the array. Each conversion specifier is replaced by the appropriate characters as shown in Table 9-2. The appropriate characters are determined by the LC_TIME category of the current locale and by the values contained in the structure pointed to by timeptr. Determines the processor time used. The clock function returns the processor time used by the program since the beginning of an event related to the program invocation. To determine the time in seconds, divide the return value by the value of the CLOCKS_PER_SEC macro. If the processor time is not available or cannot be represented, the value returned is (clock_t)-1 . (To measure the time spent in a program, call the clock function at the start of the program and subtract the return value from that of subsequent calls.) double difftime(time_t time1, time_t time0); Returns the difference between the two calendar times time1 and time0, expressed in seconds, as a double . time_t mktime(struct tm*timeptr); Converts the broken-down time, expressed as local time, in the structure pointed to by timeptr into a calendar time value with the same encoding as that of the values returned by the time function (that is, a value of type time_t ), which it returns. If the calendar time cannot be represented, the value (time_t)-1 is returned. Returns the current calendar time. If the calendar time is not available, the value (time_t)-1 is returned.
| |
privacy statement and legal notices |