Integer Format Conversion Functions

The C99 Standard added features to the C library two ways. First, it added functions to headers previously defined by C89. For example, significant additions were made to the mathematics library supported by the <math.h> header. These additional functions were covered in the preceding chapters. Second, new categories of functions, ranging from support for complex arithmetic to type-generic macros, were created, along with new headers to support them. These new library elements are described in this chapter. Keep in mind that none of the features described here are supported by C++.

The Complex Library

C99 adds complex arithmetic capabilities to C. At the outset, it is important to state that the C99 complex math library differs completely from the complex class library defined by C++. If you will be programming in C++, you will want to use the C++ complex library. The C99 complex library is appropriate only for programmers restricted to the C language.

The C99 complex library is supported by the <complex.h> header. The following macros are defined:

Macro

Expands To

complex

_Complex

imaginary

_Imaginary

_Complex_I

(const float _Complex) i

_Imaginary_I

(const float _Imaginary) i

I

_Imaginary_I (or _Complex_I if imaginary types are not supported)

Here, i represents the imaginary value, which is the square root of –1. Support for imaginary types is optional.

_Complex and _Imaginary, rather than complex and imaginary, were specified as a keywords by C99 because many existing C89 programs had already defined their own custom complex data types using the names complex and imaginary. By using the keywords _Complex and _Imaginary, C99 avoids breaking preexisting code. For new programs, however, it is best to include <complex.h> and then use the complex and imaginary macros.

The complex math functions are shown below. Notice that float complex, double complex, and long double complex versions of each function are defined. The float complex version uses the suffix f, and the long double complex version uses the suffix l. Also, angles are in radians.

Function

Description

float cabsf(float complex arg);
double cabs(double complex arg);
long double cabsl(long double complex arg);

Returns the complex absolute value of arg

float complex cacosf(float complex arg);
double complex cacos(double complex arg);
long double complex cacosl(long double
                                              complex arg);

Returns the complex arc cosine of arg

float complex cacoshf(float complex arg);
double complex cacosh(double complex arg);
long double complex cacoshl(long double
                                                 complex arg);

Returns the complex arc hyperbolic cosine of arg

float cargf(float complex arg);
double carg(double complex arg);
long double cargl(long double complex arg);

Returns the phase angle of arg

float complex casinf(float complex arg);
double complex casin(double complex arg);
long double complex casinl(long double
                                              complex arg);

Returns the complex arc sine of arg

float complex casinhf(float complex arg);
double complex casinh(double complex arg);
long double complex casinhl(long double
                                                complex arg);

Returns the complex arc hyperbolic sine of arg

float complex catanf(float complex arg);
double complex catan(double complex arg);
long double complex catanl(long double
                                              complex arg);

Returns the complex arc tangent of arg

float complex catanhf(float complex arg);
double complex catanh(double complex arg);
long double complex catanhl(long double
                                                complex arg);

Returns the complex arc hyperbolic tangent of arg

float complex ccosf(float complex arg);
double complex ccos(double complex arg);
long double complex ccosl(long double
                                            complex arg);

Returns the complex cosine of arg

float complex ccoshf(float complex arg);
double complex ccosh(double complex arg);
long double complex ccoshl(long double
                                              complex arg);

Returns the complex hyperbolic cosine of arg

float complex cexpf(float complex arg);
double complex cexp(double complex arg);
long double complex cexpl(long double
                                             complex arg);

Returns the complex value earg, where e is the natural
logarithm base

float cimagf(float complex arg);
double cimag(double complex arg);
long double cimagl(long double complex arg);

Returns the imaginary part of arg

float complex clogf(float complex arg);
double complex clog(double complex arg);
long double complex clogl(long double
                                            complex arg);

Returns the complex natural logarithm of arg

float complex conjf(float complex arg);
double complex conj(double complex arg);
long double complex conjl(long double
                                            complex arg);

Returns the complex conjugate of arg

float complex cpowf(float complex a,
                                   long double complex b);
double complex cpow(double complex a,
                                     double complex b);
long double complex cpowl(long double complex a,
                                              long double complex b);

Returns the complex value of ab

float complex cprojf(float complex arg);
double complex cproj(double complex arg);
long double complex cprojl(long double
                                             complex arg);

Returns the projection of arg onto the Riemann sphere

float crealf(float complex arg);
double creal(double complex arg);
long double creall(long double complex arg);

Returns the real part of arg

float complex csinf(float complex arg);
double complex csin(double complex arg);
long double complex csinl(long double
                                           complex arg);

Returns the complex sine of arg

float complex csinhf(float complex arg);
double complex csinh(double complex arg);
long double complex csinhl(long double
                                              complex arg);

Returns the complex hyperbolic sine of arg

float complex csqrtf(float complex arg);
double complex csqrt(double complex arg);
long double complex csqrtl(long double
                                             complex arg);

Returns the complex square root of arg

float complex ctanf(float complex arg);
double complex ctan(double complex arg);
long double complex ctanl(long double
                                            complex arg);

Returns the complex tangent of arg

float complex ctanhf(float complex arg);
double complex ctanh(double complex arg);
long double complex ctanhl(long double
                                              complex arg);

Returns the complex hyperbolic tangent of arg




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net