Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

sign and magnitude vs. two's complement

Status
Not open for further replies.

saeddawoud

Full Member level 3
Joined
Apr 27, 2007
Messages
153
Helped
6
Reputation
12
Reaction score
1
Trophy points
1,298
Activity points
2,144
magnitude vs sign

hello
what is the difference between these two representation for the binary numbers:
1- Sign and Magnitude.
2- Two's Complement. and why this name??
Regards
 

For sign and magnitude, if you're using N bits for the number, then N-1 bits are used for the magnitude (absolute) of the number and the msb is used to determine whether +ve or -ve. for example, 5 is 0101 and -5 is 1101.

For 2's complement, we usually use number of bits > largest +ve number and represent the -ve number by inverting all bits and adding '1' to the number.For example, 5 is 0101, for -5, first inverting => 1010 then adding 1 => 1011.

2's complement is the most used way for -ve number presentation because subtraction can be performed by representing the 2nd operand by the 2's complement then performing usual addition, besides zero has only one value thus can rempresent one more number than sign and magnitude for same number of bits.
 

I never understood why the Pic16XX had a subtract opcode, given that it only had 35 instructions. The complement and add instructions would have done the same thing.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top