c++ - 使用 std::acos 从 std::cos(angle) 恢复精确角度

标签 c++ std precision numerical-stability

C++标准是否保证angle == std::acos(std::cos(angle))如果angle在 [0, Pi] 范围内,或者换句话说,是否可以恢复 angle 的原始值?来自 std::cos 的结果使用 std::acos给定上述范围限制?

angle 时的边际情况是infinityNaN被省略了。

最佳答案

StoryTeller 的回答:

The standard cannot make that guarantee, simply because the result of std::cos may not be representable exactly by a double, so you get a truncation error, which will affect the result of std::acos.

关于c++ - 使用 std::acos 从 std::cos(angle) 恢复精确角度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40061120/

相关文章:

OS X 的 c++ 14 编译器

c++ - "result type must be constructible from value type of input range"创建 std::vector 时

c++ - 使用 -std=gnu++11 开关编译时出现 std::equal 错误

c++ - c++中std::min(int)的效率

python - 什么定义了 python 中的浮点精度?

c# - 将 float 转换为 double 会丢失精度但不会通过 ToString

c++ - 构造函数创建 const 对象

c++ - 警告 #2901 : [omp] OpenMP is not active; all OpenMP directives will be ignored

c++ - 最有可能使用什么方法来处理多个键以使用 STL 容器获取值?

format - 如何在 IJulia 中选择数字输出格式?