Share via


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。 如需家族中無訊息 NaN printf 標記法的詳細資訊,請參閱 printf 、 、 _wprintf_l_printf_lwprintf 、 。

備註

remquo 式會計算的 yx / 浮點餘數 f ,使 * fn = x + y *,其中 n 是整數, f 與 具有相同的正負號 x ,且 的絕對值 f 小於 的 y 絕對值。

C++ 允許多載,因此您可以呼叫採用並傳回 floatlong double 值之 remquo 的多載。 在 C 程式中,除非您使用 < tgmath.h > 宏來呼叫此函式, remquo 否則一律會採用兩 doubledouble 引數並傳回 。

如果您使用 < 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

另請參閱

數學和浮點支援
ldiv, lldiv
imaxdiv
fmod, fmodf
remainder, remainderf, remainderl