这个功能是什么以及它可以用来做什么? [英] What does the function remquo do and what can it be used for?
问题描述
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);
remquo
函数计算与余数
函数相同的余数。在
中,指向quo的对象存储一个值,其符号是x / y
的符号,其
幅度是对于x / y
的积分商数的模一致模2 ^ n
,其中
n 是一个实现定义的大于或等于3的整数。
$ b
remquo
函数返回x
REMy
即可。如果y
为零,则存储在quo
指向的对象
中的值code> 是未指定的,并且是否发生域错误或函数
返回零是实现定义的。
我知道它返回的是什么,它返回 fmod(x,y)
,但我不明白整个 quo
部分。它在语义上等于这个吗?
* quo =(int)x / y;
* quo%= n; / * n实现定义* /
我的最后一个问题是,这个函数有什么用处? / p>
编辑:正如Jeffrey Scofield所说他的答案,返回的商并不是 x / y
,但是低3位(加号)
它相当于(最大类型差异):
quo = x / y;
rem = x%y;
其中 rem
是返回值,并且 quo
作为输出参数返回。
与上述语法相比,它的优势在于它只执行一次除法操作。
Reading through the C specs I found this function:
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);
The
remquo
functions compute the same remainder as theremainder
functions. In the object pointed to by quo they store a value whose sign is the sign ofx/y
and whose magnitude is congruent modulo 2^n to the magnitude of the integral quotient ofx/y
, where n is an implementation-defined integer greater than or equal to 3.The
remquo
functions returnx
REMy
. Ify
is zero, the value stored in the object pointed to byquo
is unspecified and whether a domain error occurs or the functions return zero is implementation defined.
I understand what it returns, it returns fmod(x, y)
, but I don't understand the whole quo
part. Is it semantically equal to this?
*quo = (int) x/y;
*quo %= n; /* n implementation defined */
And my last question, for what could this function be useful?
EDIT: As Jeffrey Scofield said in his answer, the returned quotient really isn't x/y
, but the low 3 bits (plus sign) of the quotient.
It's equivalent to (up to type differences):
quo = x/y;
rem = x%y;
Where rem
is the return value, and quo
is returned as an output parameter.
Its advantage over the above syntax is that it does just one division operation.
这篇关于这个功能是什么以及它可以用来做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!