function
<cmath> <ctgmath>
remquo
double remquo (double numer , double denom , int* quot);
float remquof (float numer , float denom , int* quot);
long double remquol (long double numer, long double denom, int* quot);
double remquo (double numer , double denom , int* quot);
float remquo (float numer , float denom , int* quot);
long double remquo (long double numer, long double denom, int* quot);
double remquo (Type1 numer , Type2 denom , int* quot); // additional overloads
Compute remainder and quotient
Returns the same as remainder, but it additionally stores the quotient internally used to determine its result in the object pointed by quot.
The value pointed by quot contains the congruent modulo with at least 3 bits of the integral quotient numer/denom.
Header
<tgmath.h> provides a type-generic macro version of this function.
Additional overloads are provided in this header (
<cmath>
) for other combinations of
arithmetic types (
Type1 and
Type2): These overloads effectively cast its arguments to
double
before calculations, except if at least one of the arguments is of type
long double
(in which case both are casted to
long double
instead).
Parameters
- numer
- Floating point value with the quotient numerator.
- denom
- Floating point value with the quotient denominator.
- quot
- Pointer to an object where the quotient internally used to determine the remainder is stored as a value of type
int
.
Return Value
The remainder of dividing the arguments.
If this remainder is zero, its sign shall be that of x; In this case, the value stored in quot is unspecified.
If denominator is zero, the function may either return zero or cause a domain error (depending on the library implementation).
If a domain error occurs:
- And math_errhandling has MATH_ERRNO set: the global variable errno is set to EDOM.
- And math_errhandling has MATH_ERREXCEPT set: FE_INVALID is raised.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
/* remquo example */
#include <stdio.h> /* printf */
#include <math.h> /* remquo */
int main ()
{
double numer = 10.3;
double denom = 4.5;
int quot;
double result = remquo (numer,denom,");
printf ("numerator: %f\n", numer);
printf ("denominator: %f\n", denom);
printf ("remainder: %f\n", result);
printf ("quotient: %d\n", quot);
return 0;
}
| |
Output:
numerator: 10.300000
denominator: 4.500000
remainder: 1.300000
quotient: 2
|
See also
- remainder
- Compute remainder (IEC 60559) (function
)
- fmod
- Compute remainder of division (function
)
- fabs
- Compute absolute value (function
)
- round
- Round to nearest (function
)