Filter löschen
Filter löschen

Hi, I am wondering if the following binary number is correct for a 64-bit computer: 1011110001​.001001110​0101011000​0001000001​1001000000​0000 or should there be 52 bits after the radix point? In my case I have 43 bits after the radix point. Thank you

3 Ansichten (letzte 30 Tage)
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 Kommentare
David Goodmanson
David Goodmanson am 30 Okt. 2018
Bearbeitet: David Goodmanson am 30 Okt. 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Guillaume
Guillaume am 30 Okt. 2018
Bearbeitet: Guillaume am 31 Okt. 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 Kommentare
H
H am 31 Okt. 2018
Is my output:
753.153=1011110001.0010011100101011000000100000110001001001110
is now considered as double precision (for 64-bit computer)?

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by