Continue to Site

Welcome to

Welcome to our site! 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.

Absolute Value or Magnitude

Not open for further replies.


Newbie level 3
Oct 21, 2007
Reaction score
Trophy points
Activity points
Hello all, newbie to these boards. I have a question regarding absolute value in terms of binary. For instance (a and b are 4 bits long):

|a - b| + 1

My thoughts are do it like:

- for b, negate all the bits
- pass the negated 'b' into a full adder with 'a' as the other input. Cin of the full adder is permanently set to 1 to complete the 2's complement negation of b.
- if the Cout of this adder is 1, you know your result was negative from a-b

This is where I get fuzzy. I know how I can implement the rest of the circuit, I just don't think it's the most efficient.

- have Cout control as the select of a mux. When Cout=1, I1 of the mux gets selected.
- what feeds into this I1 input of the mux is the sum of the first full adder negated and plus 1 to convert it to it's positive version.
- what feeds into the I0 input of the mux is the just the sum of the first full adder. If Cout=0, you know this value is positive.
- another adder on the output of the mux is used to add the final + 1 as indicated in the original equation.

Can someone help me simply this so it uses less adders?? RIght now it's using three. I think two is possible but can't get it in my head, much appreciated!

Not open for further replies.

Part and Inventory Search

Welcome to