How to convert decimal into binary?
古いコメントを表示
Hello,
I need to convert n-bit decimal into 2^n bit binary number. I do not have much idea. Can anybody help me please?
4 件のコメント
Jan
2019 年 1 月 22 日
What exactly is a "n bit decimal"? Integer or floating point values? What about dec2bin?
Sky Scrapper
2019 年 1 月 22 日
編集済み: Sky Scrapper
2019 年 1 月 22 日
Jan
2019 年 1 月 22 日
2^8 or 2^8-1 ?
採用された回答
その他の回答 (2 件)
PRAVEEN GUPTA
2019 年 7 月 8 日
0 投票
i have string of number [240 25 32 32]
i want to convert them in binary
how can i do this???
2 件のコメント
Jan
2019 年 7 月 8 日
Do no attach a new question as an asnwer of another one.
Did you read this thread? dec2bin has been suggested already, as well as a hand made solution Dec2BinNumeric. Simply use them.
AB WAHEED LONE
2021 年 3 月 6 日
編集済み: AB WAHEED LONE
2021 年 3 月 6 日
I know it is late but somwhow it may help
bin_array=dec2bin(array,8)-'0';
vandana Ananthagiri
2020 年 2 月 5 日
function A = binary_numbers(n)
A = double(dec2bin(0:((2^n)-1),n))-48;
end
2 件のコメント
Walter Roberson
2020 年 2 月 5 日
Why 48?
I know the answer, but other people reading your code might not, so I would recommend either a comment or a different representation.
vincent voogt
2021 年 11 月 1 日
Maybe a late reply, but dec2bin return as string of ASCII characters, where 0-9 are mapped on character number 48-57.
カテゴリ
ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!