convert -10.978 to binary

Since the function dec2bin only works fornon negative integers, how can I convert -10.978to binary and vice versa ?

3 件のコメント

Rik
Rik 2018 年 12 月 21 日
That depends on the definition you choose. As binary is simply a two-element number system (like decimal has 10 and hexadecimal has 16), there is no fundamental reason why you couldn't have something like 1001.11001
However, as far as I know, most people will use a floating point digit. One of the links I was shown in the side bar of this question is this FEX submission Floating number conversion to binary and vice-versa, it might be worth your while to check it out.
Walter Roberson
Walter Roberson 2018 年 12 月 21 日
There are a rather large number of different binary representations for -10.978 . One of them is 1100000000100101111101001011110001101010011111101111100000000000 . One of them is 11000001001011111010010111100011 . There are many others; see https://www.mathworks.com/help/vision/ug/concepts-and-terminology.html
John D'Errico
John D'Errico 2018 年 12 月 21 日
I once wrote a tool that expands a float into a binary form.
B = [3 1 -1 -2 -3 -4 -5 -7 -10 -12 -13 -14 -15 -19 -20 -22 -24 -27 -28 -29 -30 -31 -32 -34 -35 -36 -37 -38 -41 -42 -43 -45 -46 -48 -49];
- sum(2.^B)
format long g
-sum(2.^B)
ans =
-10.978

回答 (0 件)

この質問は閉じられています。

製品

リリース

R2017b

タグ

質問済み:

2018 年 12 月 21 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by