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

15 views (last 30 days)
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 Comments
David Goodmanson
David Goodmanson on 30 Oct 2018
Edited: David Goodmanson on 30 Oct 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.

Sign in to comment.

Answers (1)

Guillaume
Guillaume on 30 Oct 2018
Edited: Guillaume on 31 Oct 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 Comments
H
H on 31 Oct 2018
Is my output:
753.153=1011110001.0010011100101011000000100000110001001001110
is now considered as double precision (for 64-bit computer)?

Sign in to comment.

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!