是CMATH EXP()和log()函数总是对称的? [英] Are cmath exp() and log() functions always symmetrical?
本文介绍了是CMATH EXP()和log()函数总是对称的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是CMATH EXP()
和日志()
函数总是对称的?
Are cmath exp()
and log()
functions always symmetrical?
人机工程学如果我这样做
Ergo if I do
double x;
double y = exp(log(x));
assert(x == y);
将永远断言失败,在这种情况下:在什么情况下?我们可以假设, X
为有理数> 0
推荐答案
一个浮点登录
不可能是一对一。它需要单调递增,满足日志(64)> 4.15
和日志(128)LT; 4.86
。有2 52 双击
64和128,但也有少于2 50 双
取值4.15和4.86之间。有多个双打
在这个范围内使用相同的双precision数,因此 EXP(日志(X))== X
必须失败其中的至少一个。
A floating-point log
cannot be one-to-one. It needs to be monotone increasing and satisfy log(64) > 4.15
and log(128) < 4.86
. There are 252 double
s between 64 and 128, but there are fewer than 250 double
s between 4.15 and 4.86. There are multiple doubles
in that range with the same double-precision logarithm, so exp(log(x)) == x
must fail for at least one of them.
这篇关于是CMATH EXP()和log()函数总是对称的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文