Conversion of [0,1] to Binary

3 ビュー (過去 30 日間)
Joe
Joe 2014 年 1 月 20 日
コメント済み: Joe 2014 年 1 月 20 日
Hi, I want to convert decimals between 0 and 1 into binary form which can be represented exactly up to 11 binary digits say, so 1/2^11, 2/2^11, 3/2^11......to 2^11-1/2^11 only, is there a good code or build in function for this?
Also, is there a function which can return the no of 1's or 0's in the binary form of a particular value above?
Thanks
Joe

採用された回答

Walter Roberson
Walter Roberson 2014 年 1 月 20 日
B = dec2bin( round(X * 2^11), 11 ) - '0';
nnz(B)
sum(B)
length(B) - nnz(B)
  1 件のコメント
Joe
Joe 2014 年 1 月 20 日
nice thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by