如何绑定浮点算术结果?
x = a/b
之类的浮点操作通常不完全表示,因此CPU必须进行舍入。是否可以获得两个浮点x_low
和x_up
,它们分别比a/b
的确切值少或等于最高的浮点。最低的浮点比a/b
更高或平等?
某些条件是:
a
,b
,x_low
,x_up
和x
是float
a
和b
是正面的,整数(1.0f
,2.0f
, ETC)
Floating-point operations like x=a/b
are usually not exactly representable so the CPU has to do rounding. Is it possible to get the two floats x_low
and x_up
that are respectively the highest floating point less or equals than the exact value of a/b
and the lowest floating point higher or equals than a/b
?
Some of the conditions are :
a
,b
,x_low
,x_up
andx
arefloat
a
andb
are positive, integers (1.0f
,2.0f
, etc)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将为您提供可能太大的范围:
This will give you a bounds that might be too large:
一种简单的方法是以更高的精度进行分区,并在转换为float时获得上/下限:
An easy way to do it is to do the division in higher precision and get the upper/lower bound on conversion to float: