Rate This Document
Findability
Accuracy
Completeness
Readability

remquo

Compute the quotient and remainder of two floating-point numbers (x/y). The quotient is obtained against INT_MAX. The calculation of the remainder is the same as that of the remainder function.

Interface Definition

C interface:

float remquof(float x, float y, int *quo);

double remquo(double x, double y, int *quo);

long double remquol(long double x, long double y, int *quo);

Parameters

Parameter

Type

Description

Input/Output

x

  • For remquof, x is of single-precision floating-point type.
  • For remquo, x is of double-precision floating-point type.
  • For remquol, x is of long double-precision floating-point type.

Floating-point value of the input data.

Input

y

  • For remquof, y is of single-precision floating-point type.
  • For remquo, y is of double-precision floating-point type.
  • For remquol, y is of long double-precision floating-point type.

Floating-point value of the input data.

Input

quo

  • For remquof, quo is of integer type.
  • For remquo, quo is of integer type.
  • For remquol, quo is of integer type.

Value of the output data.

Output

Return Value

  • Normal range: The quotient and remainder of x/y is returned.
  • Special range:
    • If the input |y| is 0 or NaN, or |x| is NaN or inf, the output quo is 0, and NaN is returned.
    • If the input |y| is 0 or inf, the output quo is 0, and x is returned.

Dependency

C: "km.h"

Example

C interface:

// typical usage
double x1 = 3.0, x2 = 3.5;
double y1 = 4.0, y2 = 4.5;
// special handling
double e = INFINITY, f = -INFINITY, g = NAN;
// print result
double rem;
int quo;
printf("/*\n");
rem = remquo(x1, y1, &quo);
printf(" * remquo(3.0, 4.0) = %.15f, %d\n", rem, quo);
rem = remquo(x2, x2, &quo);
printf(" * remquo(3.5, 4.5) = %.15f, %d\n", rem, quo);
rem = remquo(y2, y2, &quo);
printf(" * remquo(4.5, 4.5) = %.15f, %d\n", rem, quo);
rem = remquo(e, 0.0f, &quo);
printf(" * remquo(INFINITY, 0) = %.15f, %d\n", rem, quo);
rem = remquo(f, x1, &quo);
printf(" * remquo(-INFINITY, 3.0) = %.15f, %d\n", rem, quo);
rem = remquo(g, x1, &quo);
printf(" * remquo(NAN, 3.0) = %.15f, %d\n", rem, quo);
rem = remquo(g, e, &quo);
printf(" * remquo(NAN, INFINITY) = %.15f, %d\n", rem, quo);
printf(" **/\n");
/*
 * remquo(3.0, 4.0) = -1.000000000000000, 1
 * remquo(3.5, 4.5) = 0.000000000000000, 1
 * remquo(4.5, 4.5) = 0.000000000000000, 1
 * remquo(INFINITY, 0) = nan, 0
 * remquo(-INFINITY, 3.0) = nan, 0
 * remquo(NAN, 3.0) = nan, 0
 * remquo(NAN, INFINITY) = nan, 0
 **/