简体   繁体   English

IEEE 754浮点除法的可逆性

[英]Invertability of IEEE 754 floating-point division

What is the invertability of the IEEE 754 floating-point division? IEEE 754浮点除法的可逆性是什么? I mean is it guaranteed by the standard that if double y = 1.0 / x then x == 1.0 / y , ie x can be restored precisely bit by bit? 我的意思是标准保证如果double y = 1.0 / x然后x == 1.0 / y ,即x可以精确地逐位恢复?

The cases when y is infinity or NaN are obvious exceptions. yinfinityNaN时的情况是明显的例外。

Yes, there are IEEE 754 double-precision(*) values x that are such x != 1.0 / (1.0 / x) . 是的,IEEE 754双精度(*)值xx != 1.0 / (1.0 / x)

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 . 手动使用此属性很容易构建一个正常值的示例:在C99的浮点值的十六进制表示法中写入0x1.fffffffffffffp0 那个是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. 很自然地期望0x1.fffffffffffffp0是一个反例,因为1.0 / 0x1.fffffffffffffp0落在一个binade的开头,浮点数密度较小,所以最内部的分支必须发生较大的相对误差。 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. 更确切地说, 1.0 / 0x1.fffffffffffffp0恰好位于0.5和它的双精度后继之间的中点之上,因此1.0 / 0x1.fffffffffffffp0向上舍入到0.5的后继,具有较大的相对误差。

In decimal %.16e format, 0x1.fffffffffffffp0 is 1.9999999999999998e+00 and 0x1.ffffffffffffep0 is 1.9999999999999996e+00 . 在十进制%.16e格式中, 0x1.fffffffffffffp01.9999999999999998e+000x1.ffffffffffffep01.9999999999999996e+00

(*) there is no reason for the inverse function to have the property in the question for any of the IEEE 754 format (*)反函数没有理由在任何IEEE 754格式的问题中具有属性

Obviously not. 显然不是。 1/10 has no representation. 1/10没有代表。 You get an approximation instead. 你会得到一个近似值。 Inverting that will not give you 10. 颠倒那不会给你10。

Edit: there are a large number of these. 编辑:有很多这些。 Any inverse that requires more than 53 bits will be one of them. 任何需要超过53位的反转都将是其中之一。

There is an easy test. 有一个简单的测试。 In C you could test 1.0/(1.0/10.0) against 10.0 and you will discover they aren't equal. 在C中你可以测试1.0 /(1.0 / 10.0)对10.0,你会发现它们不相等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IEEE 754浮点加法和乘法的互换性 - Interchangeability of IEEE 754 floating-point addition and multiplication 浮点运算是否导致IEC 559 / IEEE 754浮点类型的无限未定义行为 - Are floating point operations resulting in infinity undefined behavior for IEC 559/IEEE 754 floating-point types 跨编译器的 IEEE-754 二进制模式一致性的浮点文字 - Floating-point literal to IEEE-754 binary pattern consistency across compilers 非IEEE754浮点类型的大小如何受到约束? - How are the sizes of non IEEE754 floating-point types constrainted? IEEE Std 754浮点:让t:= a - b,标准保证a == b + t吗? - IEEE Std 754 Floating-Point: let t := a - b, does the standard guarantee that a == b + t? 返回浮点类型是否完全符合 IEEE-754 的函数? - Function that returns whether the floating-point type is fully compliant to IEEE-754? 将IEEE-754之前的C ++浮点数与C#相互转换 - Convert pre-IEEE-754 C++ floating-point numbers to/from C# 浮点除法不完美 - Floating-point division imperfection IEEE 754浮点数,最大数&lt;1? - IEEE 754 floating point, what is the largest number < 1? 执行两次时产生不同结果的相同浮点计算是否表明不符合 IEEE 754? - Does the same floating-point calculation producing different results when performed twice indicate IEEE 754 non-conformance?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM