so adders are widely used in redstone design, why not subtractors? so if you have a subtractor design please post it here, if none are, i'm going to post mine in an hour and claim 1st :tongue.gif:

EDIT: half subtractor

there needs to be a repeater before/after that and gate, sorry

so adders are widely used in redstone design, why not subtractors? so if you have a subtractor design please post it here, if none are, i'm going to post mine in an hour and claim 1st :tongue.gif:

in modern cpu design...the working motto is 'do more with less'. adders are so popular because its a matter of messing with the input values to make the adder 'subtract'..with little change.

think about it: in math...a-b = a+(-:cool.gif:
in binary logic: a - b = !(!a + :cool.gif: ! meaning binary NOT, inverted bits.
follow it in binary..assuming 4 bits for values from 0-15:
to do 3-1
3 = 0011
1 = 0001
!3 = 1100 = 12
1100 + 0001 = 1101 = 13
!13 = !1101 = 0010 = 2 <-- final result, which is what we wanted.

most alu's (arithmetic logic units, primary component of a cpu) will have controls to let you invert an input value, and invert the output value and other little things, like zero an input (an inverted 0 input lets you do things like a=a+1). so most times, all you need is adders, and let the input circuitry handle fiddling the bits to get the result you want.

heh i see you already posted the image...nicely done :wink.gif:

in modern cpu design...the working motto is 'do more with less'. adders are so popular because its a matter of messing with the input values to make the adder 'subtract'..with little change.

think about it: in math...a-b = a+(-:cool.gif:
in binary logic: a - b = !(!a + :cool.gif: ! meaning binary NOT, inverted bits.
follow it in binary..assuming 4 bits for values from 0-15:
to do 3-1
3 = 0011
1 = 0001
!3 = 1100 = 12
1100 + 0001 = 1101 = 13
!13 = !1101 = 0010 = 2 <-- final result, which is what we wanted.

most alu's (arithmetic logic units, primary component of a cpu) will have controls to let you invert an input value, and invert the output value and other little things, like zero an input (an inverted 0 input lets you do things like a=a+1). so most times, all you need is adders, and let the input circuitry handle fiddling the bits to get the result you want.

heh i see you already posted the image...nicely done :wink.gif:

thanks for the explanation :smile.gif:

i just wrapped up a full subtractor and i'm going to post it in a bit, i'm not a huge fan of modified adders in minecraft and prefer dedicated logic gates

any suggestions for making it smaller would be amazing....it's a monster to say the least lol

Rollback Post to RevisionRollBack

When life gives you melons, you're probably dyslexic.

i just wrapped up a full subtractor and i'm going to post it in a bit, i'm not a huge fan of modified adders in minecraft and prefer dedicated logic gates

any suggestions for making it smaller would be amazing....it's a monster to say the least lol

remember...its not the adder thats changed...your simply adding logic to the inputs and outputs of the adders to make it do what i described. its not as difficult as you think :wink.gif:

remember...its not the adder thats changed...your simply adding logic to the inputs and outputs of the adders to make it do what i described. its not as difficult as you think :wink.gif:

i'll keep that in mind, thanks

Rollback Post to RevisionRollBack

When life gives you melons, you're probably dyslexic.

since the first bit indicates a -8, we can only represent up to positive 7 using 2's complement. 1000 -> 0000 -> 0111 (Range)

2's complement of a number is derived by inverting the positive natural binary representation and then adding 1.

This way you can easily turn an adder into a subtractor by inverting the value by which you wish to subtract and setting the carry-in to 1. This way B can be greater than A as long as you don't have overflow.

ok here's the final product, it's a monster to say the least....

image cut

if you notice any mistakes in my circuitry please let me know...primarily that 3 input or gate and the and gates leading into it

Your circuitry......
So large.........................
so uncompacted
it hurts.

Rollback Post to RevisionRollBack

Brilliant Troll. This guy is a mad genius

Quote from Silvermatt »

omg guiz dis is amazing it so sexi i wanna penetrate the shep so hard look at it yilow cilir
notch why u do diz yo so mean i mean look at it it so sad T~T
EDITING OP WITH PICTURES FROM THREAD:

Here's something i designed a while ago. If I remember correctly, A is on the right, B on the left, if you look at the back of the unit to see both inputs. This is basically a glorified XOR gate. But yeah, the floating output is the Borrow out and the grounded output is the regular output. Truth table for design (which is a Half-subtractor):
A | B | Output | Borrow|
0 0 0 0
1 0 1 0
0 1 0 1
1 1 1 1

Kinda proud of the little bugger really :smile.gif: It's pretty compact! And of course you could use other variations of the XOR gate and modify them, this design is just my personal preference :tongue.gif:

I just made a more clean version of this, which hopefully I'll remember to post in the morning, as it's near 2:00AM :tongue.gif:

a more complete (and complex) alu would actually do a 2's complement, but according to the book im studying, this is an efficient way to perform a subtraction without complicating the design.

not saying you shouldnt do a subtraction circuit, its a great learning exercise...but dont knock binary logic when its proven to work. for example, the same alu design im working with also has a toggle to switch the alu from adding to binary AND..and with the invert/zero bits on the inputs and invert on the output, you can get XOR, OR, and other useful functions without adding any special circuits.

EDIT: half subtractor

there needs to be a repeater before/after that and gate, sorry

in modern cpu design...the working motto is 'do more with less'. adders are so popular because its a matter of messing with the input values to make the adder 'subtract'..with little change.

most alu's (arithmetic logic units, primary component of a cpu) will have controls to let you invert an input value, and invert the output value and other little things, like zero an input (an inverted 0 input lets you do things like a=a+1). so most times, all you need is adders, and let the input circuitry handle fiddling the bits to get the result you want.

heh i see you already posted the image...nicely done :wink.gif:

thanks for the explanation :smile.gif:

i just wrapped up a full subtractor and i'm going to post it in a bit, i'm not a huge fan of modified adders in minecraft and prefer dedicated logic gates

any suggestions for making it smaller would be amazing....it's a monster to say the least lol

if you notice any mistakes in my circuitry please let me know...primarily that 3 input or gate and the and gates leading into it

remember...its not the adder thats changed...your simply adding logic to the inputs and outputs of the adders to make it do what i described. its not as difficult as you think :wink.gif:

i'll keep that in mind, thanks

The most significant bit (left-most) indicates whether the number is positive or negative. Using a 4-bit range example.

2's Comp Rep. = > Value

1000 => -8 = (-8 + 0)

1001 => -7 = (-8 + 1)

1010 => -6 = (-8 + 2)

...

1111 => -1 = (-8 + 7)

0000 => 0 = (-8 + 8)

0001 => 1 = (0 + 1)

...

0111 => 7 = (0 + 7)

since the first bit indicates a -8, we can only represent up to positive 7 using 2's complement. 1000 -> 0000 -> 0111 (Range)

2's complement of a number is derived by inverting the positive natural binary representation and then adding 1.

This way you can easily turn an adder into a subtractor by inverting the value by which you wish to subtract and setting the carry-in to 1. This way B can be greater than A as long as you don't have overflow.

Projects: Toggle Game, Connect 4 w/ Win Detection

Your circuitry......

So large.........................

so uncompacted

it hurts.

I KNOW!

i literally took my diagram i drew on my desk and transferred into minecraft, so it's a bit...uh...massive

A | B | Output | Borrow|

0 0 0 0

1 0 1 0

0 1 0 1

1 1 1 1

Kinda proud of the little bugger really :smile.gif: It's pretty compact! And of course you could use other variations of the XOR gate and modify them, this design is just my personal preference :tongue.gif:

I just made a more clean version of this, which hopefully I'll remember to post in the morning, as it's near 2:00AM :tongue.gif:

how so:

a more complete (and complex) alu would actually do a 2's complement, but according to the book im studying, this is an efficient way to perform a subtraction without complicating the design.

not saying you shouldnt do a subtraction circuit, its a great learning exercise...but dont knock binary logic when its proven to work. for example, the same alu design im working with also has a toggle to switch the alu from adding to binary AND..and with the invert/zero bits on the inputs and invert on the output, you can get XOR, OR, and other useful functions without adding any special circuits.