Math precision requirements of C and C++ standard

前端 未结 1 880
臣服心动
臣服心动 2020-12-06 05:51

Do the C and C++ standards require the math operations in math.h on floating points (i.e. sqrt, exp, log, sin

相关标签:
1条回答
  • 2020-12-06 06:29

    No, and for good reason. In general, you'd need an infinite precision (and infinite time) to determine the exact mathematical result. Now most of the times you need only a few extra iterations to determine sufficient bits for rounding, but this number of extra bits depend on the exact result (simply put: when the result is close to .5 ULP). Even determining the extra number of iterations required is highly non-trivial. As a result, requiring exact results is far, far slower than a pragmatic approach.

    0 讨论(0)
提交回复
热议问题