フィルターのクリア

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 ビュー (過去 30 日間)
H
H 2018 年 10 月 30 日
コメント済み: H 2018 年 10 月 31 日
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 件のコメント
H
H 2018 年 10 月 30 日
please see picture for more information
David Goodmanson
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
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.
  7 件のコメント
H
H 2018 年 10 月 31 日
Is my output:
753.153=1011110001.0010011100101011000000100000110001001001110
is now considered as double precision (for 64-bit computer)?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by