Name
remainder, remainderf, remainderl, remquo, remquof, remquol,
- floating-point remainder function
Library
libm.lib
Synopsis
|
double
remainder (double x, double y);
|
|
float
remainderf (float x, float y);
|
|
long double
remainder (long double x, long double y);
|
|
double
remquo (double x, double y, int *quo);
|
|
float
remquof (float x, float y, int *quo);
|
|
long double
remquol (long double x, long double y, int *quo);
|
Return values
remainder
function returns the remainder, unless
y
is zero, when the function fails.
Detailed description
The functions
remainder,
remainderf,
remquo,
and
remquof
return the remainder
r
:=
x
-
n*y
where
n
is the integer nearest the exact value of
-words x Ns / Ns Fa y
moreover if
\*(Ba n
-
x / y \*(Ba
=
1/2
then
n
is even.
Consequently
the remainder is computed exactly and
\*(Ba r \*(Ba
<=
\*(Ba y \*(Ba/2.
But attempting to take the remainder when
y
is 0 or
x
is ±oo is an invalid operation that produces a NaN.
The
remquo
and
remquof
functions also store the last
k
bits of
n
in the location pointed to by
quo,
provided that
n
exists.
The number of bits
k
is platform-specific, but is guaranteed to be at least 3.
remainderl
and
remquol
are aliases to the functions
remainder
and
remquo
respectively.
Examples
#include <math.h>
int main( )
{
double inp1 = 1.625;
double inp2 = 1.0;
double y;
y = remainder( inp1, inp2 );
printf( "remainder(%f , %f) = %f\n", inp1, inp2, y );
y = remainderf( inp1, inp2 );
printf( "remainderf(%f , %f) = %f\n", inp1, inp2, y );
y = remainderl( inp1, inp2 );
printf( "remainderl(%f , %f) = %f\n\n", inp1, inp2, y );
y = remquo( inp1, inp2 );
printf( "remquo(%f , %f) = %f\n", inp1, inp2, y );
y = remquof( inp1, inp2 );
printf( "remquof(%f , %f) = %f\n", inp1, inp2, y );
y = remquol( inp1, inp2 );
printf( "remquol(%f , %f) = %f\n", inp1, inp2, y );
}
Output
remainder ( 1.625, 1.0) = -0.375
remainderf ( 1.625, 1.0) = -0.375
remainderl ( 1.625, 1.0) = -0.375
remquo ( 1.625, 1.0) = -0.375
remquof( 1.625, 1.0) = -0.375
remquol( 1.625, 1.0) = -0.375
See also
fmod,
ieee,
math
Feedback
For additional information or queries on this page send feedback
© 2005-2007 Nokia
|
|