Matlab function 2 convert negative decimals to signed binary values

Status
Not open for further replies.

vickyuet

Member level 2
Joined
Oct 3, 2006
Messages
50
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
pakistan
Activity points
1,691
Dear All,

I need to convert signed/unsigned decimals to their equivalent signed binary values in Matlab.I had used 2 functions but they work for positive integers only i.e de2bi() and dec2bin().Is there any function that help me or I had to write my own routine for conversion.

Regards,
 

Hi;
If you know your number of bits in binary, you can do smthng like this, (for decimal numbers smaller than zero);
Let say 4 bit binary represantation;
Then ie -3 complementary number is 2^4+(-3)=13
13 in binary form (here use dec2bin or de2bi) [1101]. If you consider this number in signed manner it corresponds to -3 (take 1's complement and add 1 **broken link removed**).

Hope helps
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…