C++标准是否保证angle == std::acos(std::cos(angle))
如果angle
在 [0, Pi] 范围内,或者换句话说,是否可以恢复 angle
的原始值?来自 std::cos
的结果使用 std::acos
给定上述范围限制?
angle
时的边际情况是infinity
或 NaN
被省略了。
最佳答案
StoryTeller 的回答:
The standard cannot make that guarantee, simply because the result of
std::cos
may not be representable exactly by adouble
, so you get a truncation error, which will affect the result ofstd::acos
.
关于c++ - 使用 std::acos 从 std::cos(angle) 恢复精确角度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40061120/