Windows 中 C99 lrint 函数的正确替代方法是什么?
#define lrint(x) (floor(x+(x>0) ? 0.5 : -0.5))
/* and if fesetround(0) behavior is required*/
#define lrint(x) ((int)(x))
这是正确的吗?
最佳答案
没有[简单]单一的lrint
定义来执行C99标准定义的行为。这是因为 lrint
的行为是通过单独调用 fesetround
来控制的。 。相反,您应该使用具有保证语义的单独舍入函数来实现应用程序的所需行为。
关于C++ Windows 打印的替代品?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15319494/