# Problem of displaying addition and subtraction in decimal form on 2 Digits 7 segments in Proteus

I want to finish an addition and subtraction circuit inside the Proteus program, and display the sum and subtraction result in decimal on 7-segment displays, see below diagram.
The problem with my circuit is that it shows and counts as long as the result is below 9, but when I count the number above 9, it shows wrong.
I want the numbers on the 7 segments to be displayed only in decimal, not hex.
And I want my calculations to be done between the numbers 0 to 31 because I add two four-bit values and the sum of these two eventually reaches 31, and I want to do subtraction as well.
My circuit does addition and subtraction correctly, the only problem is displaying it.
See in the picture, I added a 2nd 9 to 9 and the result should be 18 and it shows 32, which is wrong.

• Why do you duplicate the lowest bit of the second displayed digit? If you would not have done that, the display would show "12" which, in Hex, is the sum of 9 and 9. Commented Oct 31, 2021 at 9:00
• @StarCat No 4 bits above 9 and 4 bits below 9 and two 9s are added together and the result is 18 and the number 18 should be displayed on 7 pieces but this is not true. If you know the solution, help me, thank you
– Good
Commented Oct 31, 2021 at 9:07
• @Good There are BCD adders in the 7400 series: 74583 for example. Are you saying you are limited to just 7 devices (where an adder is considered one, each digit display is considered one, and each xor is considered one?) Also, I think you mean added 9 to 9 to get 18?
– jonk
Commented Oct 31, 2021 at 9:14
• Is the “display” a Hex display (which I think is the case based on the circuit’s behavior), a BCD display or does it translate an 8-bit value into its decimal representation? The output of the LS83 adder is in binary and not in BCD as you seem to expect. And could you please explain why you duplicate the carry out bit. Commented Oct 31, 2021 at 9:16
• @StarCat By entering two 4-bit numbers, my circuit performs sub and add operations and displays the result in 2 digit 7 segments. For example, I want to add the binary number 1111 with the binary number 1001. Display the numbers in decimal, but it does not work correctly. Did you understand the meaning?
– Good
Commented Oct 31, 2021 at 9:25

You are counting in binary. That means if you add 9 and 9 (you wrote "added 2 to 9", but from picture and expectation of 18, it seem you meant "added two nines") you get $$0001 \space 0010$$ which is 18 in binary and would be "12" in hexadecimal (Yours shows incorrectly 3, because you connected two bits together for whatever reason, so it reads 0011 instead of just 0001). Conversion to hex is easy, as each group of 4 bits refers to one digit in hex (0001 is 1, 0010 is 2). Converting to decimal is not at all that simple (because 10 is not the power of two, its a pitty that we don't have 8 or 16 fingers, our life would be easier :D).
Alternative way is using BCD (binary coded decimal). That is way of representing decimal number in bits, by using 4 bits for each digit. For example 18 would be $$0001 \space1000$$ first part (0001) is 1, second (1000) is 8. each group of 4 bits ranges from 0000 to 1001 (=9).
This representation is what you would need. Unfortunately it is not that straightforward, because BCD no longer behaves as a mathematical number. Imagine you incremented that number by one at a time: You start with $$0000\space 0000$$ next is $$0000\space 0001$$ this continues up to nine $$0000\space 1001$$ after adding one to nine, it would normally become $$0000\space 1010$$ which is 0 and 10, but you need it to become $$0001\space 0000$$ meaning 1 and 0 so 10. So you need the adding to overflow and carry bit at 1001 (9) instead of 1111 (15). This is called decimal correction.
A way to implement this would be: If the result is greater than 9, add additional 6 to make it owerflow and carry to next bit:$$0000\space 1010$$ is 10 in binary. Add 6 and it becomes$$0001\space 0000$$ which is 16 in binary, but 10 in BCD.