PS-Trainer C - Entwicklung
Mathematik: Logarithmus, Exponent
Homepage von PS-Trainer - C-Entwicklung - Mathematik - an PS-Trainer
PS-Trainer PS-Trainer

Math and related Logarithm and Exponent
exp Calculate the exponential.
log Calculate logarithms.
ldexp

Compute a real number from the mantissa and exponent.

frexp
Get the mantissa and exponent of a floating-point number.


exp
Calculates the exponential.
double exp( double x );

Function Required Header Compatibility
exp <math.h> ANSI, Win 95, Win NT

Subject: Floating-Point Support Routines
Keywords: See also log
Return Value
The exp function returns the exponential value of the floating-point parameter, x, if successful. On overflow, the function returns INF (infinite) and on underflow, exp returns 0.

Parameter
x Floating-point value
Example
/* EXP.C */

#include <math.h>
#include <stdio.h>

void main( void )
{
double x = 2.302585093, y;

y = exp( x );
printf( "exp( %f ) = %f\n", x, y );
}


Output
exp( 2.302585 ) = 10.000000


log, log10
Calculates logarithms.
double log( double x );
double log10( double x );


Routine Required Header Compatibility
log <math.h> ANSI, Win 95, Win NT
log10 <math.h> ANSI, Win 95, Win NT

Subject: Floating-Point Support Routines
Keywords: See Also exp, _matherr, pow
Return Value
The log functions return the logarithm of x if successful. If x is negative, these functions return an indefinite (same as a quiet NaN). If x is 0, they return INF (infinite). You can modify error handling by using the _matherr routine.

Parameter
x Value whose logarithm is to be found

Example
/* LOG.C: This program uses log and log10
* to calculate the natural logarithm and
* the base-10 logarithm of 9,000.
*/

#include <math.h>
#include <stdio.h>

void main( void )
{
double x = 9000.0;
double y;

y = log( x );
printf( "log( %.2f ) = %f\n", x, y );
y = log10( x );
printf( "log10( %.2f ) = %f\n", x, y );
}


Output
log( 9000.00 ) = 9.104980
log10( 9000.00 ) = 3.954243


ldexp
Computes a real number from the mantissa and exponent.
double ldexp( double x, int exp );

Routine Required Header Compatibility
ldexp <math.h> ANSI, Win 95, Win NT

Subject: Floating-Point Support
Keywords: See also frexp, modf
Return Value
The ldexp function returns the value of x * 2exp if successful. On overflow (depending on the sign of x), ldexp returns +/– HUGE_VAL; the errno variable is set to ERANGE.

Parameters
x Floating-point value
exp Integer exponent

Example
/* LDEXP.C */

#include <math.h>
#include <stdio.h>

void main( void )
{
double x = 4.0, y;
int p = 3;

y = ldexp( x, p );
printf( "%2.1f times two to the power of %d is %2.1f\n", x, p, y );
}

Output
4.0 times two to the power of 3 is 32.0


frexp
Gets the mantissa and exponent of a floating-point number.
double frexp( double x, int *expptr );

Routine Required Header Compatibility
frexp <math.h> ANSI, Win 95, Win NT

Remarks
The frexp function breaks down the floating-point value (x) into a mantissa (m) and an exponent (n), such that the absolute value of m is greater than or equal to 0.5 and less than 1.0, and x = m*2n. The integer exponent n is stored at the location pointed to by expptr.

Subject: Floating-Point Support Routines
Keywords: See also ldexp, modf
Return Value
frexp returns the mantissa. If x is 0, the function returns 0 for both the mantissa and the exponent. There is no error return.

Parameters
x Floating-point value
expptr Pointer to stored integer exponent
Example
/* FREXP.C: This program calculates frexp( 16.4, &n )
* then displays y and n.
*/

#include <math.h>
#include <stdio.h>

void main( void )
{
double x, y;
int n;

x = 16.4;
y = frexp( x, &n );
printf( "frexp( %f, &n ) = %f, n = %d\n", x, y, n );
}

Output
frexp( 16.400000, &n ) = 0.512500, n = 5


Homepage von PS-Trainer - C-Entwicklung - Mathematik - an PS-Trainer

Aktuelle Daten dieser Seite Letzte Änderung:
  Geocities

 

 

 

Hosted by www.Geocities.ws

1