IEEE 754浮点除法的可逆性 [英] Invertability of IEEE 754 floating-point division

查看:139
本文介绍了IEEE 754浮点除法的可逆性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IEEE 754浮点除法的可逆性是什么?我的意思是,该标准是否保证如果double y = 1.0 / x然后x == 1.0 / y,即x可以精确地一点一点恢复?

What is the invertability of the IEEE 754 floating-point division? I mean is it guaranteed by the standard that if double y = 1.0 / x then x == 1.0 / y, i.e. x can be restored precisely bit by bit?

yinfinityNaN的情况是明显的例外.

The cases when y is infinity or NaN are obvious exceptions.

推荐答案

是的,IEEE 754双精度(*)值x就是x != 1.0 / (1.0 / x).

Yes, there are IEEE 754 double-precision(*) values x that are such x != 1.0 / (1.0 / x).

使用此属性可以轻松构建一个正常值的示例:在0x1.fffffffffffffp0编写的示例/> C99的浮点值十六进制表示法就是1.0 / (1.0 / 0x1.fffffffffffffp0) == 0x1.ffffffffffffep0.很自然地期望0x1.fffffffffffffp0是一个反例,因为1.0 / 0x1.fffffffffffffp0落在binade的开头,在那里浮点数的密度较小,因此最里面的除法必须发生较大的相对误差.更准确地说,1.0 / 0x1.fffffffffffffp0恰好位于0.5及其双精度后继字符之间的中点上方,因此1.0 / 0x1.fffffffffffffp0舍入为0.5的后继字符,具有较大的相对误差.

It is easy to build an example of a normal value with this property by hand: the one that's written 0x1.fffffffffffffp0 in C99's hexadecimal notation for floating-point values is such that 1.0 / (1.0 / 0x1.fffffffffffffp0) == 0x1.ffffffffffffep0. It was natural to expect 0x1.fffffffffffffp0 to be a counter-example because 1.0 / 0x1.fffffffffffffp0 falls at the beginning of a binade, where floating-point numbers are less dense, so a larger relative error had to happen on the innermost division. More precisely, 1.0 / 0x1.fffffffffffffp0 falls just above the midpoint between 0.5 and its double-precision successor, so that 1.0 / 0x1.fffffffffffffp0 is rounded up to the successor of 0.5, with a large relative error.

以十进制%.16e格式,0x1.fffffffffffffp01.9999999999999998e+00,而0x1.ffffffffffffep01.9999999999999996e+00.

In decimal %.16e format, 0x1.fffffffffffffp0 is 1.9999999999999998e+00 and 0x1.ffffffffffffep0 is 1.9999999999999996e+00.

(*)对于任何IEEE 754格式,没有理由使反函数具有该属性.

(*) there is no reason for the inverse function to have the property in the question for any of the IEEE 754 format

这篇关于IEEE 754浮点除法的可逆性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆