简体   繁体   中英

Floating point representation of a real number is not unique

I am reading about floating point representation of real numbers.
In any real number system with arithmetic base β, a real number x can be represented as
x=(0.d 1 d 2 --- d t d t+1 ---) β X β e (1)
where 0≤d i ≤β-1
Now consider (0.5) 10 in binary system.
In binary system, (0.5) {10} =(0.1) 2 (2)
But we can see that 1/2=(1/2 2 )+(1/2 3 )+----
(0.5) 10 =(0.01111---) 2 (3)

From (2) and (3) we can see that the same number has two floating point representation.

I have read that such ambiguities can be removed by considering the "normalized floating point representation" ie,
d 1 ≠ 0

But with the normalized floating point representation, we still have the ambiguity.
(0.5) 10 =(0.100000) 2 (2(a))
(0.5) 10 =((0.1111111----) X 2 -1 ) (3(a))

So from (2(a)) and (3(a)) we can see that the ambiguity is not resolved still even with normalized floating point representation. Can somebody please tell whether I am right. And how to resolve this ambiguity?

... with the normalized floating point representation, we still have the ambiguity.

No ambiguity.


(2(a)) (0.5) 10 = (0.100000) 2
(3(a)) (0.5) 10 = ((0.1111111----) 2 X 2 -1

(2(a)) is true.
(3(a)) is false as the number of terms in a floating point value is finite. This is no more true than 1.0 equals 0.999999999999999.

With common binary floating point, all finite values have only 1 encoding, except +0.0 and -0.0.

(3(a)) (0.5)10 = ((0.1111111----)2 X 2-1 is true.  **BUT** real world floats are finite, so 0.1111111---- does not exist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM