remquo, remquof, remquol

计算两个整数值的余数,并将一个带有商的符号和近似值的整数值存储在参数中。

语法

double remquo( double numer, double denom, int* quo );
float remquof( float numer, float denom, int* quo );
long double remquol( long double numer, long double denom, int* quo );
#define remquo(X, Y, INT_PTR) // Requires C11 or higher

float remquo( float numer, float denom, int* quo ); /* C++ only */
long double remquo( long double numer, long double denom, int* quo ); /* C++ only */

参数

numer
分子。

denom
分母。

quo
指向整数值的指针,以存储带有商的符号和近似值的值。

返回值

remquo 返回 x / y 的浮点余数。 如果 y 的值为 0.0,则 remquo 返回静态 NaN。 有关 printf 系列表现静态 NaN 形式的信息,请参阅 printf_printf_lwprintf_wprintf_l

备注

remquo 函数计算 x / y 的浮点余数 f,以便 x = n * y + f*(其中 n 是一个整数),f 具有与 x 相同的符号,且 f 的绝对值小于 y 的绝对值。

C++ 允许重载,因此,可以调用采用并返回 floatlong double 值的 remquo 重载。 在 C 程序中,除非使用 <tgmath.h> 宏调用此函数,否则 remquo 始终采用两个 double 参数并返回 double

如果使用 <tgmath.h>remquo() 宏,则参数的类型将决定选择哪个版本的函数。 有关详细信息,请参阅泛型类型数学

默认情况下,此函数的全局状态范围限定为应用程序。 若要更改此行为,请参阅 CRT 中的全局状态

要求

功能 必需的标头 (C) 必需的标头 (C++)
remquo, remquof, remquol <math.h> <cmath> 或 <math.h>
remquo <tgmath.h>

有关兼容性信息,请参阅兼容性

示例

// crt_remquo.c
// This program displays a floating-point remainder.

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

int main( void )
{
   double w = -10.0, x = 3.0, z;
   int quo = 0;

   z = remquo(w, x, &quo);
   printf("The remainder of %.2f / %.2f is %f\n", w, x, z);
   printf("Approximate signed quotient is %d\n", quo);
}
The remainder of -10.00 / 3.00 is -1.000000
Approximate signed quotient is -3

另请参阅

数学和浮点支持
ldivlldiv
imaxdiv
fmodfmodf
remainderremainderfremainderl