From: Vivian Richy on
Hey ,
can anyone explain me the difference between 2^-1024 and 1/(2^1024) in ieee double precision format.
Thanks in advance
From: James Tursa on
"Vivian Richy" <vivianrichy(a)gmail.com> wrote in message <hjm25t$4ok$1(a)fred.mathworks.com>...
> Hey ,
> can anyone explain me the difference between 2^-1024 and 1/(2^1024) in ieee double precision format.
> Thanks in advance

Sounds like homework again, but I will answer. IEEE double precision has a range for the normalized numbers. You can get it easily using MATLAB as follows:

>> realmax
ans =
1.797693134862316e+308
>> realmin
ans =
2.225073858507201e-308

If you look at your first number, it is outside this range. In particular, it is one of the so-called denormalized numbers with exponent bits exactly 000. e.g.,

>> 2^-1024
ans =
5.562684646268004e-309
>> format hex
>> realmin
ans =
0010000000000000 % exponent bits 001
>> 2^-1024
ans =
0004000000000000 % exponent bits 000

So you can see it is a factor of 4 less than the smallest normalized number.

Now look at realmax:

>> format hex
>> realmax
ans =
7fefffffffffffff

The exponent bits are 7fe hex, a decimal value of 2046. The IEEE double exponent has a bias of 1023, so this bit pattern actually represents a value of 2^(2046-1023) = 2^1023. This, along with the mantissa bits being all set, means realmax is very close to, but slightly less than, 2^1024 because the mantissa is a number slightly less than 2. Calculating 2^1024 exceeds realmax, so you get infinity. When you divide by it, you get zero.

>> 2^1024
ans =
Inf
>> 1/2^1024
ans =
0

James Tursa
From: Vivian Richy on
"James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hjm5ed$269$1(a)fred.mathworks.com>...
> "Vivian Richy" <vivianrichy(a)gmail.com> wrote in message <hjm25t$4ok$1(a)fred.mathworks.com>...
> > Hey ,
> > can anyone explain me the difference between 2^-1024 and 1/(2^1024) in ieee double precision format.
> > Thanks in advance
>
> Sounds like homework again, but I will answer. IEEE double precision has a range for the normalized numbers. You can get it easily using MATLAB as follows:
>
> >> realmax
> ans =
> 1.797693134862316e+308
> >> realmin
> ans =
> 2.225073858507201e-308
>
> If you look at your first number, it is outside this range. In particular, it is one of the so-called denormalized numbers with exponent bits exactly 000. e.g.,
>
> >> 2^-1024
> ans =
> 5.562684646268004e-309
> >> format hex
> >> realmin
> ans =
> 0010000000000000 % exponent bits 001
> >> 2^-1024
> ans =
> 0004000000000000 % exponent bits 000
>
> So you can see it is a factor of 4 less than the smallest normalized number.
>
> Now look at realmax:
>
> >> format hex
> >> realmax
> ans =
> 7fefffffffffffff
>
> The exponent bits are 7fe hex, a decimal value of 2046. The IEEE double exponent has a bias of 1023, so this bit pattern actually represents a value of 2^(2046-1023) = 2^1023. This, along with the mantissa bits being all set, means realmax is very close to, but slightly less than, 2^1024 because the mantissa is a number slightly less than 2. Calculating 2^1024 exceeds realmax, so you get infinity. When you divide by it, you get zero.
>
> >> 2^1024
> ans =
> Inf
> >> 1/2^1024
> ans =
> 0
>
> James Tursa


Hey James,
itz actually statement in the homework problem. But i couldn't get it. I thought they are the same. Thank you very much for your help.
Richy