Hi, I am wondering if the following binary number is correct for a 64-bit computer: 1011110001.0010011100101011000000100000110010000000000 or should there be 52 bits after the radix point? In my case I have 43 bits after the radix point. Thank you
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I am wondering if the following binary number is correct for a 64-bit computer:
1011110001.0010011100101011000000100000110010000000000
or should there be 52 bits after the radix point? In my case I have 43 bits after the radix point.
Thank you
6 Commenti
David Goodmanson
il 30 Ott 2018
Modificato: David Goodmanson
il 30 Ott 2018
Hi H, To see how it works out, 'format hex' is interesting, e.g.
format hex
1/3
3fd5555555555555
-1/3
bfd5555555555555
1/2
3fe0000000000000
.1
3fb999999999999a
etc.
Risposte (1)
Guillaume
il 30 Ott 2018
Modificato: Guillaume
il 31 Ott 2018
I believe I've already given you a simple piece of code to convert any number to its IEEE754 double precision representation.
dec2bin(typecast(yourdoublenumber, 'uint64'), 64)
edit: as pointed out by David, this actually doesn't work because dec2bin does some rounding. See comments below for a reliable method
the representation of 753.153 as IEEE-754 double is not what you have at all. For a start IEEE-754 doesn't use an integer.fraction encoding. The encoding is significand*base^exponent. In addition, IEEE-754 doesn't store the exponent as is, a bias is added to it. For double precision, the bias is 1023. Finally, for all numbers except denorms, the leading 1 of the significand is not stored.
753.153 in IEEE-754 is stored as roughly 1.4710019531251 * 2^(1032-1023). The 1.47... significand in binary is 1.0111100010010011100101011000000100000110001001001110b. As said, the leading 1 is not stored. The exponent 1032 in binary is 10000001000b, so 753.153 in IEEE-754 is
0 10000001000 0111100010010011100101011000000100000110001001001110
where I've separated sign, exponant and significand (fraction) by a space.
post edited to correct some of the binary representation which was incorrectly generated by dec2bin. The gist of the post has not changed.
7 Commenti
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!