フィルターのクリア

carry addition in a binary number

9 ビュー (過去 30 日間)
Prashant Funde
Prashant Funde 2016 年 3 月 29 日
編集済み: James Tursa 2018 年 9 月 10 日
I have a number which is in 2's complement form, i wanted to make it in general binary form. So please tell me is there any direct function available for the same?
Or please tell me how can i add carry 1 in the first bit and consecutively in the upcoming bits also. if i have a binary vector: 1 0 0 1 1 1 and i have to add 1 as a carry then my answer will be 1 0 1 0 0 0. but how can get this in MATLAB.
Thanks in adavnce
  1 件のコメント
James Tursa
James Tursa 2018 年 9 月 10 日
編集済み: James Tursa 2018 年 9 月 10 日
It is unclear what you really want. How is your current number stored? As one of the integer classes? In a floating point class? In a string or char class? Where did these digits come from? How many "bits" wide (i.e., where is the sign bit)? Etc ...?
And what exactly do you want as a result? Can you provide an explicit example of input and output for us?

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

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 3 月 29 日
v='100111'
w=dec2bin(bin2dec(v)+1)
  1 件のコメント
Anirudh Thandra
Anirudh Thandra 2018 年 9 月 10 日
This does not work if the binary numbers are in the matrix form and not a character form.

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

カテゴリ

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