gpt4 book ai didi

c - remquo 函数的作用是什么?它有什么用途?

转载 作者:太空狗 更新时间:2023-10-29 17:06:47 24 4
gpt4 key购买 nike

通过阅读 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-defined 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 unspecified and whether a domain error occurs or the functions return zero is implementation defined.

我理解它返回什么,它返回 fmod(x, y),但我不理解整个 quo 部分。它在语义上等于这个吗?

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

最后一个问题,这个函数有什么用?

最佳答案

remquo() 的典型用法是减少三角函数参数。商的最后 3 位将允许一个人知道一个角度位于哪个半象限,在减少模 Pi/4 之后,并将原始 trig 调用转换为另一个在 [0,Pi/内的角度的 trig 调用4) 区间(新的触发函数可能不同)。后者通常通过 Pade 近似计算。

关于c - remquo 函数的作用是什么?它有什么用途?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9349990/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com