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
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
David Goodmanson
2018 年 10 月 30 日
編集済み: David Goodmanson
2018 年 10 月 30 日
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.
回答 (1 件)
Guillaume
2018 年 10 月 30 日
編集済み: Guillaume
2018 年 10 月 31 日
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.
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!