![]() |
C - Entwicklung Mathematik: Absolutwerte, Runden und Abschneiden Homepage von PS-Trainer - C-Entwicklung - Mathematik - an PS-Trainer |
|
| Math and related | Absolute Values, Rounding, Truncation: |
| abs | Calculate the absolute value of an integer argument. |
| cabs | Calculates the absolute value of a complex number. |
| fabs | Calculate the absolute value of a real argument. |
| labs | Calculate the absolute value of a long integer. |
| floor | Calculate the floor of a value. |
| ceil | Calculate the ceiling of a value. |
| modf
|
Split a real value into fractional and integer parts. |
| abs Calculates the absolute value. int abs( int n );
Subject: Data Conversion Routines, Floating-Point Support Keywords: See Also _cabs, fabs, labs |
||||||
| Return Value The abs function returns the absolute value of its parameter. There is no error return. Parameter
|
||||||
|
Example #include <stdio.h> void main( void ) iy = abs(
ix ); ly = labs(
lx ); dy = fabs(
dx ); |
| _cabs Calculates the absolute value of a complex number. double _cabs( struct _complex z );
Remarks The _cabs function calculates the absolute value of a complex number, which must be a structure of type _complex. The structure z is composed of a real component x and an imaginary component y. A call to _cabs produces a value equivalent to that of the expression sqrt( z.x*z.x + z.y*z.y ). Subject: Floating-Point Support Routines Keywords: See Also abs, fabs, labs |
||||||
| Return Value _cabs returns the absolute value of its argument if successful. On overflow _cabs returns HUGE_VAL and sets errno to ERANGE. You can change error handling with _matherr. Parameter
|
||||||
| Example /* CABS.C: Using _cabs, this program calculates * the absolute value of a complex number. */ #include <math.h> #include <stdio.h> void main( void ) d = _cabs( number ); |
|
fabs
Subject: Floating-Point Support Routines |
||||||
| Return Value fabs returns the absolute value of its argument. There is no error return. Parameter
|
||||||
|
Example #include <stdio.h> void main( void ) iy = abs( ix ); ly = labs( lx ); dy = fabs( dx ); |
| labs Calculates the absolute value of a long integer. long labs( long n );
Subject: Data Conversion Routines, Floating-Point Support Keywords: See Also abs, _cabs, fabs |
||||||
| Return Value The labs function returns the absolute value of its argument. There is no error return. Parameter
|
||||||
| Example /* ABS.C: This program computes and displays * the absolute values of several numbers. */ #include <stdio.h> void main( void ) iy = abs( ix ); ly = labs( lx ); dy = fabs( dx ); |
| ceil Calculates the ceiling of a value. double ceil( double x );
Subject: Floating-Point Support Routines Keywords: See Also floor, fmod |
||||||
| Return Value The ceil function returns a double value representing the smallest integer that is greater than or equal to x. There is no error return. Parameter
|
||||||
| Example /* FLOOR.C: This example displays the largest integers * less than or equal to the floating-point values 2.8 * and -2.8. It then shows the smallest integers greater * than or equal to 2.8 and -2.8. */ #include <math.h> void main( void ) y = floor( 2.8 ); y = ceil( 2.8 ); |
| floor Calculates the floor of a value. double floor( double x );
Subject: Floating-Point Support Routines Keywords: See Also ceil, fmod |
||||||
| Return Value The floor function returns a floating-point value representing the largest integer that is less than or equal to x. There is no error return. Parameter
|
||||||
| Example /* FLOOR.C: This example displays the largest integers * less than or equal to the floating-point values 2.8 * and -2.8. It then shows the smallest integers greater * than or equal to 2.8 and -2.8. */ #include <math.h> void main( void ) y = floor( 2.8 ); y = ceil( 2.8 ); |
| modf Splits a floating-point value into fractional and integer parts. double modf( double x, double *intptr );
Remarks The modf function breaks down the floating-point value x into fractional and integer parts, each of which has the same sign as x. The signed fractional portion of x is returned. The integer portion is stored as a floating-point value at intptr. Subject: Floating-Point Support Routines, Long Double Keywords: See Also frexp, ldexp |
||||||
| Return Value This function returns the signed fractional portion of x. There is no error return. Parameters
|
||||||
|
Example #include <math.h> void main( void ) x = -14.87654321; /* Divide
x into its fractional */ printf( "For %f, the
fraction is %f and the integer is %.f\n", |
| Aktuelle Daten dieser Seite | Letzte Änderung: |
| |