Redstone Binary Subtraction - LRR #5
Vložit
- čas přidán 16. 06. 2024
- In this episode, we explore negative number formats and build a toggleable adder/subtractor.
Patreon: / mattbatwings
Discord: / discord
My socials: linktr.ee/mattbatwings
My texture pack: modrinth.com/resourcepack/mat...
World Download: (JAVA 1.18.2) www.planetminecraft.com/proje...
Overflow Detection in 2's Complement • Twos Complement Additi...
-------------------------
Want to get more involved in the logical redstone community?
Learn Logical Redstone! • Logical Redstone Reloaded
Open Redstone Engineers (ORE): openredstone.org/
0:00 Introduction
1:01 Signed Magnitude
3:08 Modular Arithmetic
6:23 Two's Complement
8:56 Building a Subtractor
9:46 Building a Toggleable Adder/Subtractor
11:30 Sentiment
12:34 Another Cool Fact
13:08 One's Complement
13:37 Subscribe!
Music (in order):
Infraction - Photograph • Vlog lo-fi Anime Fashi...
Harris Heller - Guilty Spark • Guilty Spark
Infraction - Sapporo • Lo-Fi Anime Fashion Ch...
Harris Heller - Plethora • Plethora
Gareth Coker - Firefly in a Fairytale (Veritasium Theme) • Firefly in a Fairytale...
Alexander Nakarada - Favorite • Favorite
LuKremBo - Biscuit • (no copyright music) l...
Harris Heller - Streamline • Streamline
Harris Heller - Iridescent • Iridescent
Infraction - Serotonin • Vlog Lo-Fi Chill by In...
PRNV - Happy High • Happy High || happy lo...
Milky Wayvers - Love in Japan • Love in Japan
Harris Heller - In My Shadow • In My Shadow
Harris Heller - Manhattan Project • Manhattan Project
Harris Heller - Singularity • Singularity
Mellowind - Bored • Bored || Vibin in the 80s - Hry
lrr is such a force of nature, not even SICKNESS could stop HIM!!!
he actually just made a redstone machine that recorded and deepfaked this video
@@darqed can you shut up?!!?
And ALSO THAT IS WRONG
Um...Redstone machines can't replicate audio yet - try again when redstone computers are fully implemented.
yeah? OMW to grabbing rabbies (I will be a famous person and get money for acting as if I treated him)
I can stop him
GUYS WE FINALLY KNOW WHY INVERTING AND ADDING 1 WORKS!!! I'M SO HAPPY :)
Watch some Sebastian league and his how computers work series
yeah that was my first introduction to binary systems and boolean algebra@@darqed
Matt explains the most complex thing so well is not normal
Your dad
@@cmtg461 🤔?
12:40 You can also see how thinking about the last bit has a negative value shows the inversion by the series of numbers counting up from negative 8.
I always liked this way of seeing two's complement because it's the one that makes the more sense to me.
Since a single bit's value is exactly the sum of all previous bits + 1, making it negative forces the final value to fall in negative space (-1 being the smallest absolute value).
This also automatically invert the order in which the absolute value increments/decrements which then creates the emergence of all the other advantages listed in the video :)
As a developer with a computer science degree, I of course knew about two's compliment; but I never stopped to wonder *why* the conversion algorithm of "invert + 1" works. When you showed the algebraic connection to modular arithmetic, my mind was blown. Thank you for the education! 🙂
I never thought about it, but as soon as he said people would wonder, I automatically assumed that N bits go up to a value of 2^N-1. Inverting means +1.
I don't even like minecraft. I'm a computer scientist and these videos are a really entertaining way of relearning what I already know in a new environment. Great work!
how to pay taxes?
@@alibrahym it depends on your government. Please contact an appropriate agency of your government.
@@samuelhulme8347 How to date women?
@@alibrahym please ask someone else. I do not know.
@@samuelhulme8347 what is the true religion?
Love that veritasium music when explaining using clock
And 3blue1brown's math animation library at that as well!
It's kinda weird to me that you learned two's complement using modular arithmetic before learning the negating most significant bit trick. I learned it other way around and, honestly, your way is probably better, because knowing math behind why it works is better than just blindly use the trick.
It's not really taught that way, true. I advocated for the modular arithmetic theory as its an easier model to imagine.
Au-delà de l'aspect Minecraft, c'est même super bien expliqué sur l'aspect de l'informatique
bien joué à toi et bisous de France
J'avoue il est trop fort
Le fait qu'il l'explique sur minecraft ça donne un aspect plus convivial aussi
@@pomelo9518 no I didn't know him
What is the link between the fact that I'm french and him?
@@pomelo9518 of course
@@Dimitri_gdr il est français, même si son contenu est en anglais
I learn more in 1 min 30s with this video than in 5 years of school with professors
CS student here; great videos. It was by sheer chance I happened to watch one of these before my first class on low level computing, and now I always hear my professor talking about the things you do here. Really well done.
Great revision of my comp sci classes with a Minecraft aspect on top, love it!
This video actually made me understand Why two’s complement exists and why it works! Thank you from a current computer science major
this is the first time I'm actually enjoying math class
thank you for these videos
Great vid as always, keep up the work Matt
This is the best explanation of 2’s Complement I’ve heard so far! Thank you!
It's hard for me to process this, but it's good. Love that you show how it works on practice so it was A LOT easier to understand. Hope to see more of this.
You are actually the best. These are so well explained, and amazingly made. Learning these concepts on fun and easy, keep it up!
Your actually making computer science even more fun and understanding. Thanks A LOT
These videos are great, I am learning so much! Thank you for this awesome series!
This series is incredible!
Recently decided I wanted to learn redstone in its entirely, and although this focuses more on redstone logic instead of the whackier items like pistons, skulk, and observers. I really feel like this is foundational knowledge that I'll be able to take advantage of in future projects and learnings.
Absolutely amazing work, my man, thank you.
we already knew about two's compliment, but hearing that it's based on modular arithmetic made us truly understand it for the first time!!
I love the way you introduced two's complement
Ive been waiting for this one. Ive been trying to make a calculator on bedrock then noticed your binary episode, knew youd cover subtraction eventually
This was much easier to understand, than I thought
I don't even know if this stuff is in my CS curriculum. I'm super grateful for these videos!
I would really love it if you would do one video for multiplication and one for division. I know that you already covered those two but it would perfectly fit into your new series of tutorials. I really love this series! I am a CS student and I have been following redstone stuff for ages now, so I do find it easy to follow the technical stuff but I am not good with compact designs hence I appreciate this channel so much! Maybe I should try build a redstone computer again when I got time. Thank you and keep going with your amazing work! :D
oh I didnt know the trick to interpret two's complement numbers, that's great!
i'm glad you explained twos complement. i always thought of negative numbers in binary as the last place being negative. i.e: 4 bits would be -8,4,2,1
Finally another LRR episode!
this is also a good series it helped me alot
a good way to think about two's complement is to consider the last bit to represent the negative of what it does for the regular binary. For example, with four bits 1011 would be -8 + 2 + 1 which is -5, and inverting and adding 1 gives 0101 which is 4 + 1 = 5.
Edit: Oh, it's already in the video
OMG A NEW VID!!!!
The 3blue1brown music really made this feel so professional😂
Keep up the great work, you really are one of the best logical redstoners in the world
Finally a New awesome episode
wow, that's a lot simpler than I tought :)
I remember first learning this in a computer architecture class. The things you can do with 2's complement... it's awesome. Also, abusing that overflow to do a comparison is nice - literally just need to check one bit (though equality still requires more).
Also props for not calling -7 + -7 = 2 an underflow. Still overflow 👍
Love this video 🙌🏻🙌🏻🙌🏻
finally a 2s comp explanation i can live with xd
I’m using this video to study for my ece midterm
Oh finally he has recovered!❤
Very good explanation and detail awesome matt, sorry I can't join patreon first because I don't have dollar bills introduce me from Indonesia 😊
👏👏👏 Я сделал механизм который может как складывать так и вычитать два отрицательных числа. Чтобы тебе сделать такой нужно:
1)к механизму сложения добавить еще один;
2)добавить инверсию к входу сигнала с двух сторон (у тебя в видео с одной стороны);
3)соединить инверсии с сумматором с помощью логического элемента "или";
4)соединить инверсии логическим элементом "и";
5)соединить этот логический элемент с вторым сумматором ко второй платформе.
Если что-то не понятно спроси меня об этом.
Если хочешь могу скинуть на почту, но только укажи на какую.
Best videos on CZcams
I love this
So my dad builds parts for rockets, and he couldn't comprehend why you add one when negating a binary number, I thought that was hilarious
this is very interesting.
Love da vids
I remember making my first calculator in minecraft and copying circuit for comparison of A and B (If A>B, then result is +, if A=B then 0, and if A
*goes to make popcorn to watch with*
i love you matbat
8:55 Also, if you are more focused on the results than the math behind it, you can think of the +1 as avoiding having -0 and thus having to increment twice to get past 0 (-1 -> -0 -> +0 -> +1). It's not an actual proof, but I think it can be helpful to remember. (Edit: this also causes problems in 1's complement)
have you looked into the recent Posit: A Potential Replacement for IEEE 754?
nice
when making the toggleable adder/subtractor an easier way to do it is just have the toggle lever run power into the side of all the redstone torches making them toggle the inversion.
gonna get back to building computers in minecraft thanks to this, thank you
Edit: Nevermind, I kept watching the video and I realized I wrote a stupid comment haha! I'm keeping it here for the engagement though! Great video!
Finally, Oh also you were sick last week, you ok?
Additionally, it's worth pointing out some terminology here for values to make things clearer: in 13 \equiv 1 (mod 12), 1 is called the residue. The residue is the value that is the result of computing the remainder of a congruence, in this case the congruence 13 \equiv 1 (mod 12), per Wolfram MathWorld (amazing "encyclopedia"; go check it out!). Also don't worry about what \equiv here is. It's the name for the congruence symbol in LaTeX which lets you render mathematical notation so that it's neat and readable the same way we can text with a keyboard.
The Veritasium music in the explanation at 4:31 lol
i learned more here than i did during math in school
probably because they'd cover this in computer science and not math lol
Finally!!
Hello matt where can i find your texturepack? think it looks really good.
11:53 Nice pun
I like your funny words magic man
What you built at 11:07 was a 1 bit 4-bit ALU
God I love negative binary numbers
GCSE Computer Science taken a year early with little prior knowledge was hell when I got to Two’s complement
Binary subtraction in just 2 adic addition . Veritasium made a video on it.
can you show us how to make a binary to bcd converter like the double dabble algorithm in one of the next episodes??
if you add a multiplier and a diviser you can make a full ALU
I was powering thru untili hit this video.... This is the third day i' m stuck on this video. This was just a hard concept to comprehend, for now i know enough to move on i feel.
Will you be covering serial circuits?
how did you made such compact adder mine is like giant just for 1 bit is like half of yours and this is just adder with carry and 2 inputs (even using pistons for few gates
can you make a block by block tutoroial for the toggle subtractor / adder
Cool
Hi! Do you have a degree in computer engineering or in computer science? Because by looking at your insane builds it looks like that you have a lot of knowledge about computers
Positive zero and negative zero matters if you work with decimal points. But if it is just zero, it's the same.
its interesting that when doing the example -7-7 in binary the anwser is +2 which added to the opposite of the real anwser is 16
this also works with numbers i think
1010=-6
1000=-8
=0010=2 in decimal
-6-8 would be -14 so it always adds up to 16 which is cool i guess
or maybe im just an idiot i paused to write this and idk if he talks about it after its just an intresting thought
Use do to all of this in little bug planet lol it's cool seeing it in Minecraft
A good way to invert it is have a switch that you can turn on and off to do 1(invert) 0(normal) and connect it to an xor gate and if I have the switch on 1 and the input as 1 it will output 0 and if I input zero as the input then it will become 1
Here’s the truth table
Input | Output
0 0| 0
1 0| 1
0 1| 1
1 1| 0
As you can see this is the exact truth table of an xor gate
Hay, can you create the soggy cave redstone puzzle?
can you show how to make a 4-tick CCA because i cant find a tutorial
I find myself wondering how far this will go. Will you be implementing a programming language to quickly write redstone programs in MineCraft? Have something that can generate all the blocks in a blank level that you could pull in to do whatever. Would be quite the extension language. Granted, not as fast as something like Lua would be, but certainly interesting.
Funnily enough there is a mod called ComputerCraft or similar that let's you instruct little machines using Lua scripting lol
@@Gandhi_Physique That's interesting too, though I didn't mean as a means of automating things in the game but just to generate chunks of redstone blocks.
Now I don't know if this could be useful or even relevant but I might have found something quite helpful for these subtractors or something equivalent to that, lemme explain rq.
In your introduction at 0:19, I immediately noticed a pattern in the substraction form where :
1-0=0 / 0-1=1 / 0-0=0 / 1-1=0
Didn't get the time to test all of that myself but can't logic gates try to calculate and process that and maybe directly output the result?
I'd be interested to hear more on that thing, maybe I'm just very wrong LOL
He did mention you can implement the standard subtraction algorithm in circuitry. But if you already have an adder, it's more efficient to reuse that for subtraction instead of creating a separate circuit to do it.
Love from india bro
My problem, if i want an accurate number by it said to invert one part, my problem is if i invert it then if i press 1 so 1110 basically becomes 2 so the invert button is just annoying to people who am trina show this to and they might press 1 and think it's removing 1 but it was actually 2 :(
i learned alot, but i have a question because i'm from spain and don't understand english so well. What X means? (in the explanation part). And another thing that i wanted to ask is, how do you aply the formula for detecting the overflow?
4:29 Veritasium vibes right here
"S.M." is also called two's complement.
whoops!
YESSIRR
matt putting Vsauce music in his video 👌
dude, hearing the veritassium music made me feel like i was learning faster.
To change the adder to a subtractor would a stack of redstone torches on pistons not also work?
You can‘t move Redstone torches with a piston. They‘d break😬
@@saynator never thought you could, you'd use a solid block to Dock. But a torch tower in must other regards right
@@sarchlalaith8836 i suppose if you also ran the unaltered input to the adder and made that run through where the blocks would be befofre they were pushed sure, but sounds like a lot of work and pistons are a messy system
I used a full adder chain, and it only worked if carry in was off and the inputs were inverted.
Edit: I inverted both inputs.
Edit: removing the torches on one of the input bytes (I used an 8-bit adder) made 00000111 - 00000100 = 11111101
And now i'm wondering, if this trick also could be applied over multiplication/division... I mean, you probably know, that division is a multiplication with 1/number or multiplication with the number^-1
Well, no, but actually yes.
Normal integers are _integers,_ and as such can't represent fractions, but we've also already accepted that -7 - 7 = 2, so we've already abandoned traditional integer arithmetic anyways.
Let's look at what happens if we were to multiply, say, 11 by 3 with 4 bits (1011 × 0011). This is like saying 11 + 2(11) = 1011 + 0110 = 0001... That's just 1! Much like how 11 can be interpreted -5 as a signed integer, it can also be interpreted as ⅓ as a fraction.
However, most computers treat integer division the traditional way: 1/3 = 0 remainder 1, so the two approaches give very different results for most values. If the traditional remainder is 0 however, then the two results would agree, so 12/3, 15/3, 9/3, 6/3, 3/3, or with signed values: -6/3 and -3/3.
While these examples were with 4 bits, much like 2's complement, the idea works for any number of bits.
I always liked redstone, the day I got my Xbox, I was like “I need a big door.” Now I don’t build doors and do this.
Can you type 0 = xy tan(tan(xy)) on your graphing calculator
my X-Or-Gates stops working when I try to rebuild my adders to subtractors and it basically turns on every lamp in the output, I think the problem could be in where one of the inputs for the Gate is situated, but it connects to the same redstone dust, so can that be the problem and if no do you know what it could be?
Me too idk
The redstone is actually quite simple.
Is that the way computers do Addition and Subtraction?
It’s the most common way