加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

函数remquo做了什么以及它可以用于什么?

发布时间:2020-12-16 02:59:06 所属栏目:百科 来源:网络整理
导读:通过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); The remquo functions compute the same remainder as the remainder f
通过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);

The remquo functions compute the same remainder as the remainder functions. In
the object pointed to by quo they store a value whose sign is the sign of x/y and whose
magnitude is congruent modulo 2^n
to the magnitude of the integral quotient of x/y,where
n is an implementation-de?ned integer greater than or equal to 3.

The remquo functions return x REM y. If y is zero,the value stored in the object
pointed to by quo is unspeci?ed and whether a domain error occurs or the functions
return zero is implementation de?ned.

我理解它返回的内容,它返回fmod(x,y),但我不理解整个部分.它在语义上是否与此相同?

*quo = (int) x/y;
*quo %= n; /* n implementation defined */

我的最后一个问题是,这个功能有用吗?

解决方法

编辑:正如杰弗里斯科菲尔德在 his answer所说,返回的商实际上不是x / y,而是商的低3位(加号).

它相当于(最多类型差异):

quo = x/y;
rem = x%y;

其中rem是返回值,quo作为输出参数返回.它优于上述语法的优点是它只进行一次除法运算.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读