C remquo() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
math.h

Definition

In C, remquo() returns a remainder like remainder() and also writes a few low bits of the quotient into an int pointer. That helps when you need both leftover and direction information.

You pass x, y, and a pointer quo. The function returns the remainder as a double and stores a signed integer related to the quotient through quo. Include <math.h>.

Only some bits of the quotient are guaranteed (implementation-defined count, at least 3). Use them as a hint, not as a full integer division result.

Syntax

Pass dividend, divisor, and a pointer for quotient bits. Start with this call.

C
remquo(5.1, 3.0, &q);
CallWhat it does
remquo(5.1, 3.0, &q);Returns the remainder and stores quotient bits in q.

Include <math.h>. On GCC, link with -lm. quo must point to a valid int.

Library declarations
C
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);

Parameters

ParameterDescription
xRequired. The dividend.
yRequired. The divisor. It must not be 0.
quoRequired. Pointer to an int that receives some quotient bits (with sign).

Return Value

Return ValueDescription
RemainderSame style of remainder as remainder().
Via quoStores a signed value with low-order quotient bits.

C Examples

Example 1 — Basic Remainder and Quotient Bits

Call remquo and print both the remainder and the stored integer.

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

int main(void) {
    int q = 0;
    double r = remquo(5.1, 3.0, &q);

    printf("remainder = %.1f\n", r);
    printf("quo bits  = %d\n", q);
    return 0;
}

How It Works

  1. Declare q. An int will receive quotient bits.
  2. Call remquo. Pass the address with &q.
  3. Read remainder. Same IEEE-style leftover as remainder.
  4. Read q. Here the nearby quotient bits show 2.

Example 2 — Quotient Bits Keep a Sign

Negative inputs can flip the sign of the stored quotient information.

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

int main(void) {
    int q1 = 0;
    int q2 = 0;
    double r1 = remquo(-5.1, 3.0, &q1);
    double r2 = remquo(5.1, -3.0, &q2);

    printf("r1=%.1f q1=%d\n", r1, q1);
    printf("r2=%.1f q2=%d\n", r2, q2);
    return 0;
}

How It Works

  1. Flip x. Negative dividend changes signs.
  2. Flip y. Negative divisor also affects the pair.
  3. Watch q. Stored bits carry a sign.
  4. Pair them. Use remainder and quo together for argument reduction.

Example 3 — Remainder Matches remainder()

Show that the returned leftover agrees with a plain remainder call.

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

int main(void) {
    int q = 0;
    double x = 10.75;
    double y = 2.5;
    double a = remquo(x, y, &q);
    double b = remainder(x, y);

    printf("remquo    = %.2f (q=%d)\n", a, q);
    printf("remainder = %.2f\n", b);
    return 0;
}

How It Works

  1. Same x and y. Keep inputs identical.
  2. Call remquo. Capture remainder and bits.
  3. Call remainder. No quotient pointer needed.
  4. Compare leftovers. Printed remainders match.

Frequently Asked Questions

remquo(x, y, &q) returns a remainder like remainder() and stores some quotient bits in q.
x is the dividend, y is the divisor, and quo is a pointer to an int for quotient bits. All are required.
It returns the floating remainder. Quotient bit information is written through the quo pointer.
Include <math.h>. On GCC, link with -lm.
Both compute a similar remainder. remquo also reports a few bits of the corresponding quotient through an int pointer.

Next: rint()

Round a floating value to a nearby integer using the current rounding mode.

rint() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful