Mathematical Redstone Circuits 7: Negative numbers and Binary Subtraction

preview_player
Показать описание
In this video we talk about how negative numbers are handled in binary and how you can use them to create a binary subtractor.
Рекомендации по теме
Комментарии
Автор

To do subtraction, you turn the second input to a negative number. So for example, you'd be doing 15 + -7 instead of just 15 + 7. You convert to negative numbers by inverting the second number and then adding 1.

bennyscube
Автор

HOW DO PEOPLE HAVE SUCH GOD DAMN BIG BRAINS!!!! HE PROBABLY DOESN'T READ THIS OFF A SCRIPT, AT ALL!!! YOU ARE A

MrSirBurpsAlot
Автор

"You don't get negative 0... unless you're on drugs" I love your teaching and humor. Hope to see you on the RDF some day. ;)

MClightOfDay
Автор

At some point, yes. You can either just assign these numbers to bits directly, or you can use something called floating point, which is somewhat more complicated. I am planning on doing tutorials on the latter at some point in this series, but for now I'm covering how integer operations work, since they're simple and lead into the more complex floating point methods.

bennyscube
Автор

Hey, i met you on the rdf server (probably a few days ago once you read this), and found you very helpful with what time i had. i had to do some chores. Thanks for helping!

cookielamaproduction
Автор

Awesome video, these are finally getting challenging, but that's a good thing!

Dccopus
Автор

btw, thanks. this video is much better and easier to follow than the one before the last one.

rcollins
Автор

Ah! I think I figured it out on my own. it took me a while. The only way to switch the output to Not-Input seems to be by using an XOR! (or xnor like in the video toward the end). I tried making it simpler or with less ticks, and found that i'd have to make a whole second arithmetic unit... AND THEN still have to have a way of switching which unit to choose from.

So it seems this is the simplest way. And thanks again for this video. I appreciate your work. :)

rcollins
Автор

It's a bit confusing, but it's so easy to convert from negative binary to two's complement and back, that you really don't need to worry about it unless you are trying to make things very compact and fast.

MClightOfDay
Автор

If you want to repeat the carry line, the easiest way to do so is by putting a repeater underneath the upper bits and replacing the upper block with glowstone.

If you don't want to do a repeater, the best way is just to make a different XNOR that doesn't require the extra block for the last bit.

bennyscube
Автор

Such a cool way to show this visually, I do prefer LogiSim, but this is so cool!! Gj!

eevee
Автор

Simple: In negative numbers the most significant bit (So in 8 bits its the bit that would normally represent 128) is reserved for determining if it's positive or negative.

bennyscube
Автор

Actually if you're doing negative numbers in any form, you generally will use the last bit to determine if the number is positive or negative, because otherwise the information will be either lost or you will end up with more bits of information than you put in. You can still do it that way if you wish, it's just not ideal in most cases.

bennyscube
Автор

Benny, great video but i have one question... what would you do if you have the case of two negative numbers i.e -3 -5? Wouldn't it be the same thing as addition (so you would get 8) but only with a negative sign?

rubixmaster
Автор

so you just have to add a xor gate to the adder to make it subtraction and have negative numbers?

OsuFan
Автор

There are multiple ways of explaining 2's compliment. However I have only seen the definition "NOT +1" in minecraft tutorial videos. But it can also easily be proven it with: A+!A+1=Cout (carry out), so -A=!A+1-Cout, so if the Cout would be on after a subtracting the answer would be positive.
Another way is that the normally the most significant bit has a negative value, for instance a for bit number the first 3 bits would have the values 1, 2 and 4, however the 4 bit would have the value of -8.

kwinvdv
Автор

Sounds interesting! I'd love to see it sometime! :D

bennyscube
Автор

Hey benny! I was wondering if you could ever do a tutorial on how to work with numbers smaller than 1. Like 0, 5 and 0, 25. The problem about working with these kind of numbers (I feel), is that you never know wether it is below 1 or not, if you understand? Might explain a bit better to you if i see you on the RDF-server.

Deadfoxable
Автор

you sound like the abridged version of yugi moto still cool though :D

OmaOmaO
Автор

how do you get around the issue with the carry being to long and not reaching without putting a repeater in the lower part. doing this stops the piston from cutting the carry signal and you get an incorrect carry. 128-64 will get you 192.

tvuspen