<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>coding for beginners Archives - NeuralLantern.com</title>
	<atom:link href="https://www.NeuralLantern.com/tag/coding-for-beginners/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.NeuralLantern.com/tag/coding-for-beginners/</link>
	<description></description>
	<lastBuildDate>Sun, 20 Jul 2025 09:16:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.NeuralLantern.com/wp-content/uploads/2025/04/cropped-2025-04-04-Lantern-03-32x32.png</url>
	<title>coding for beginners Archives - NeuralLantern.com</title>
	<link>https://www.NeuralLantern.com/tag/coding-for-beginners/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Master Stacks: Fun Guide to Data Structures, LIFO &#038; Real-World Uses</title>
		<link>https://www.NeuralLantern.com/master-stacks-fun-guide-to-data-structures-lifo-real-world-uses/</link>
					<comments>https://www.NeuralLantern.com/master-stacks-fun-guide-to-data-structures-lifo-real-world-uses/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 20 Jul 2025 09:15:59 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[browser history stack]]></category>
		<category><![CDATA[call stack]]></category>
		<category><![CDATA[coding for beginners]]></category>
		<category><![CDATA[computer science basics]]></category>
		<category><![CDATA[data reversing]]></category>
		<category><![CDATA[data structure basics]]></category>
		<category><![CDATA[data structures tutorial]]></category>
		<category><![CDATA[learn coding]]></category>
		<category><![CDATA[LIFO data structure]]></category>
		<category><![CDATA[programming tutorials]]></category>
		<category><![CDATA[push pop stack]]></category>
		<category><![CDATA[stack data structure]]></category>
		<category><![CDATA[stack in C++]]></category>
		<category><![CDATA[stack operations]]></category>
		<category><![CDATA[stack programming]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=186</guid>

					<description><![CDATA[<p>Learn stacks: fun guide to data structures, LIFO, &#038; uses like browser history. Clear diagrams for beginners!</p>
<p>The post <a href="https://www.NeuralLantern.com/master-stacks-fun-guide-to-data-structures-lifo-real-world-uses/">Master Stacks: Fun Guide to Data Structures, LIFO &amp; Real-World Uses</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Master Stacks: Fun Guide to Data Structures, LIFO &amp; Real-World Uses" width="1380" height="776" src="https://www.youtube.com/embed/mAqB77KUUKY?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Want to nail down stacks? This beginner-friendly video breaks down the stack data structure with clear diagrams and a laid-back vibe. We’ll walk you through how stacks work, why they reverse data (hello, LIFO &#8211; Last In, First Out), and how they’re used in real-world stuff like browser history, undo features in editors, and even the call stack in your code. Whether you’re just starting out or brushing up on data structures, we keep it simple with hands-on demos of pushing, popping, and checking stack size—no boring jargon here! Subscribe for more coding tutorials to level up your skills, and let us know in the comments what you want to learn next. Check out our site via the QR code in the video for more coding goodness!</p>



<p>Introduction to Stack 00:00:00<br>Explaining Stack Concept 00:00:06<br>Drawing Stack Diagram 00:00:30<br>Adding Elements to Stack 00:00:53<br>Stack Rules and Operations 00:01:16<br>Pop Operation and Interface 00:06:09<br>Stack Size and Empty Check 00:07:59<br>Tracing Stack Operations 00:11:46<br>Stack as Data Reverser 00:17:44<br>LIFO/FILO Explanation 00:21:13<br>Stack Use Cases 00:24:10<br>Call Stack Mention 00:26:18<br>Conclusion and Subscribe Request 00:27:21<br>Outro and Website Promotion 00:28:34</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hello there.</p>



<p>In this video, I&#8217;m going to show you a data structure called a stack.</p>



<p>We&#8217;re going to make a diagram of it.</p>



<p>We&#8217;re going to explain how it works.</p>



<p>We&#8217;re going to look at its typical interface,</p>



<p>and we&#8217;re just going to kind of work through the concept</p>



<p>of what is a stack and what does it do and all that stuff.</p>



<p>Where&#8217;s your daddy and what does he do?</p>



<p>So for starters, what am I talking about?</p>



<p>What am I talking about?</p>



<p>Let me open up a little notepad here.</p>



<p>And I&#8217;m going to start drawing.</p>



<p>A stack is pretty simple when you first think about it.</p>



<p>It just takes a little bit more work to really get all the details down.</p>



<p>Imagine I have a data structure and maybe like at the bottom here,</p>



<p>there&#8217;s like some grass.</p>



<p>And so we can say that the data structure is empty when we first start.</p>



<p>Okay, so there&#8217;s kind of a stack here, but it&#8217;s empty.</p>



<p>So there&#8217;s nothing really on screen.</p>



<p>Imagine then I wanted to add integers into this stack.</p>



<p>So I&#8217;m going to say let&#8217;s add the integers eight and then two and then three and then four for some reason.</p>



<p>Okay, so how do we do this?</p>



<p>The first thing we do is we take the eight and we just put it on top of the stack.</p>



<p>You can imagine this as a stack of boxes or a stack of books or a stack of whatever.</p>



<p>When we add items, we&#8217;re always going to add to the top of the stack.</p>



<p>When the stack is empty, we&#8217;re obviously just going to add like at the very bottom, you know, at the ground floor.</p>



<p>But that&#8217;s sort of the top.</p>



<p>when we add the two here the next thing that happens is we just put the two on top of the eight</p>



<p>and the next thing that we do is we uh put the three on top of the two and so forth right so</p>



<p>it&#8217;s important to understand a few a few rules about stacks let me add that four real fast</p>



<p>in stacks you&#8217;re only allowed to add to the top or remove from the top you&#8217;re not allowed to add</p>



<p>or remove from anywhere else let me put a t for top right here so basically you&#8217;re allowed to add</p>



<p>So basically you&#8217;re allowed to add and remove from the top.</p>



<p>So if I wanted to add, let&#8217;s say a 12, the 12 would have to go on top of the four.</p>



<p>It couldn&#8217;t go anywhere else in this data structure.</p>



<p>And if I wanted to remove data from this stack, I could only remove the four.</p>



<p>I could not remove the three or two or the eight or anything.</p>



<p>You&#8217;re also not allowed to look at the middle of the stack.</p>



<p>You&#8217;re not allowed to look anywhere but the top.</p>



<p>So if I wanted to look at the three, the two or the eight, I wouldn&#8217;t be allowed to do it.</p>



<p>I can only look at the four.</p>



<p>look at the four and if I want to see that three I have to pop the four off</p>



<p>first in order to just see what&#8217;s under it and technically unless you have the</p>



<p>data you added memorized somewhere else you probably shouldn&#8217;t know what&#8217;s under</p>



<p>the four until you actually remove it okay so we can add and remove from the</p>



<p>top we can&#8217;t look in the middle we can&#8217;t look at the bottom or anything like that</p>



<p>and let&#8217;s do a little let&#8217;s do a little sequence of pops let me show you what</p>



<p>So first off, you can imagine a stack is sort of like a vector or a list with less functionality or more restrictions.</p>



<p>It&#8217;s useful to add restrictions on top of more robust data structures for the purposes of, I don&#8217;t know, kindling your imagination or allowing yourself to use easier implementations or whatever.</p>



<p>If you&#8217;re a musician or artist, probably at some point you&#8217;ve been stumped and you&#8217;ve had writer&#8217;s block and you can&#8217;t figure out what to create.</p>



<p>can&#8217;t figure out what to create so uh you know i know sometimes musicians when they get writer&#8217;s</p>



<p>block they&#8217;ll they&#8217;ll go to the swap meet and they&#8217;ll buy like an old dusty dirty uh casio</p>



<p>keyboard from 1985 and then they&#8217;ll write a full song just with that one piece of equipment and it</p>



<p>really stirs their creativity or it sparks their creativity and then when they&#8217;re done then they&#8217;ll</p>



<p>probably upgrade to better equipment but anyway so there&#8217;s there&#8217;s a bunch of different reasons to</p>



<p>use you know lesser data structures although this is not really lesser it&#8217;s very useful</p>



<p>It&#8217;s very useful in its own right.</p>



<p>So let&#8217;s see the interface.</p>



<p>So what can we do in a stack?</p>



<p>I&#8217;m going to put S for stack.</p>



<p>Actually, I&#8217;m just going to type this up as code.</p>



<p>No need to use the pen the whole entire time.</p>



<p>Let&#8217;s see.</p>



<p>So I&#8217;m going to put S for stack.</p>



<p>Maybe I&#8217;ll say, you know, stack that holds integers.</p>



<p>And I&#8217;ll just put an S here.</p>



<p>If you don&#8217;t know how to code right now, at this point in your career, just bear with</p>



<p>me.</p>



<p>variable of type stack and in C++ these stacks you know stacks are a template of data structure</p>



<p>which means the integers that we are holding inside of the stack they could be any other data</p>



<p>type that we wanted to including custom classes so in C++ we would use these angle brackets to</p>



<p>say I want my stack to hold integers and then I&#8217;m going to say s is the variable that I&#8217;ll use for</p>



<p>the stack so but this is not really a programming video this is just about stacks so if I wanted to</p>



<p>stack to push something like onto the top of the stack i would use the the method push the method</p>



<p>push usually has this prototype let&#8217;s see i&#8217;ll do stack push and it usually takes in a t type element</p>



<p>and again the t type it&#8217;s a templated data type which means right now if i just declared a stack</p>



<p>that was of type integer it holds integers then the t would actually expand under the hood in c</p>



<p>hood in C++ anyway at compile time to be an integer. So it would be like typing int e, right?</p>



<p>So whenever I type t, just understand that that means one instance of a thing that you could put</p>



<p>into the stack. So we&#8217;ve got a push here and usually the return type is void and it takes in</p>



<p>one element to push. And that means if I&#8217;m going to actually call, let me put some comments here.</p>



<p>If I&#8217;m going to actually call push on the stack, I&#8217;ve got to give it something to push and the</p>



<p>type of the thing that I&#8217;m pushing has to match what the stack was declared to hold. So in this</p>



<p>case, it&#8217;s integers. So I&#8217;m going to put an eight to match the diagram up above. And then after that,</p>



<p>maybe I wanted to push another number. So it&#8217;s going to be a two. And I&#8217;m just going to match</p>



<p>what the diagram has up above. So eight, two, three, four. So that&#8217;s the interface for pushing</p>



<p>usually in C++. And other languages should be similar. The other thing you can do with stacks</p>



<p>We haven&#8217;t done that yet, but let me show it to you first.</p>



<p>POP usually comes in two forms,</p>



<p>depending on what implementation you&#8217;re looking at.</p>



<p>So sometimes POP returns nothing.</p>



<p>It simply removes an item from the top of the stack.</p>



<p>And sometimes it returns a copy of the item</p>



<p>that you&#8217;re actually removing.</p>



<p>So I&#8217;m going to put like stack here and then like stack</p>



<p>just to show you that it&#8217;s inside of the namespace.</p>



<p>Oh, I don&#8217;t know.</p>



<p>Maybe that&#8217;s too C++y.</p>



<p>I&#8217;ll get rid of that stuff.</p>



<p>Hold on.</p>



<p>hold on so we&#8217;ll maybe do this just to show you that we have three separate</p>



<p>parts to this little code snip so sometimes pop doesn&#8217;t give you a copy of</p>



<p>the thing it removes sometimes it gives you a copy of the thing it removes in</p>



<p>cases where pop does not give you a copy of the thing it removes then you would</p>



<p>probably want to call top right before you popped and top will return a copy of</p>



<p>Just to clarify, if I wanted to remove something and get a copy of it and I had this line 13</p>



<p>form of pop from whatever implementation I was using, then well, I would just call pop</p>



<p>and I would do something like this, you know, auto element equals, you know, the stack dot</p>



<p>pop.</p>



<p>And what would happen is under the hood, it removes the item and then it also returns</p>



<p>a copy to me.</p>



<p>Sorry for being too C++ in this video.</p>



<p>On the other hand, if I have the form that has void for pop,</p>



<p>then I would have to do something like this.</p>



<p>I&#8217;d have to say auto element equals stack.top just to get a copy first,</p>



<p>get a copy of that for before I remove it.</p>



<p>And then when I&#8217;m finished, then I can say s.pop just to grab a copy of it and then remove it.</p>



<p>So for now, we&#8217;re just going to use the form that gives you a copy of the data</p>



<p>at the same time that you&#8217;re removing it.</p>



<p>thing to keep in mind let&#8217;s see there are two other functions i wanted to mention mention real</p>



<p>fast so for now i&#8217;m going to say that we only have the t pop type you can also check to see if a stack</p>



<p>is uh is empty and you can also check its size uh usually those are functions that have those names</p>



<p>but i&#8217;m going to do let&#8217;s see boolean empty and then i&#8217;m going to say size type size again sorry</p>



<p>an unsigned 64-bit integer so just like a count or a size something that&#8217;s just</p>



<p>going to be a whole number and never negative so we have this little</p>



<p>interface that this data structure has and we have been calling push so far so</p>



<p>let&#8217;s go ahead and do some pops I&#8217;m gonna say auto auto elements equals s</p>



<p>dot pop maybe I&#8217;ll do two of those in a row maybe instead of calling that</p>



<p>just so that we can have different variables to put our pops in.</p>



<p>And then maybe after that, I&#8217;ll do some more pushes.</p>



<p>I&#8217;ll say, let&#8217;s push like a 15 and let&#8217;s push like a 25.</p>



<p>And then I think that means it&#8217;s probably time to erase that,</p>



<p>the top part of the diagram with the 8, 2, 3, 4</p>



<p>in favor of just whatever pushes and pops we&#8217;re doing.</p>



<p>So let me just do this real fast.</p>



<p>Okay, so we did our pushes.</p>



<p>two three four and then I&#8217;m going to try to grab a couple pieces of data with these pops</p>



<p>and for pop all you have to do is just to well I should have mentioned this before but first</p>



<p>check to make sure that there is something to pop for example if I had a blank stack let&#8217;s say I had</p>



<p>a blank stack right here there&#8217;s just like nothing on it and this green line is non-standard I&#8217;m just</p>



<p>drawing it for fun but imagine I had a blank stack with no items and I decided to call pop on it</p>



<p>well you&#8217;re not allowed to pop them an empty stack there&#8217;s nothing there to pop which means that&#8217;s a</p>



<p>stack there&#8217;s nothing there to pop which means that&#8217;s a really really naughty thing in c++ and</p>



<p>other languages we would say that something exceptionally bad has happened the user tried</p>



<p>to pop something that wasn&#8217;t there and so then we would do something called throwing an exception</p>



<p>at the user again this is not really a code video but if you know a little code hopefully you</p>



<p>understand try catch blocks and throwing exceptions when bad things happen so we would just throw an</p>



<p>exception at the user if you don&#8217;t know how to code at this point then just keep in mind we would</p>



<p>mind we would refuse to do it we would say something bad has happened we can&#8217;t do that</p>



<p>and then when you&#8217;re doing your pushes sometimes depending on what what you&#8217;re using to implement</p>



<p>the stack under the hood inside of your code you might decide that you&#8217;re using let&#8217;s say you&#8217;re</p>



<p>using an array under the hood which has a fixed capacity if you run out of capacity and you can&#8217;t</p>



<p>then you would throw if the user tried to push something into a full stack we would call that a</p>



<p>stack overflow and then when we tried to pop from an empty stack we would call that stack underflow</p>



<p>but for the purposes of this video just assume that the stack is just a diagram and it has no</p>



<p>capacity so we can just add as many things as we want on it or maybe we&#8217;re using a linked list</p>



<p>under the hood which would have an unlimited capacity or limited only by the machine&#8217;s</p>



<p>But anyway, so let&#8217;s go ahead and try to do this pop.</p>



<p>So let&#8217;s do a pop here.</p>



<p>Well, in the pop, we just look at the top only, right?</p>



<p>So we say, well, you know what?</p>



<p>Let&#8217;s make this more interesting.</p>



<p>Hang on a second.</p>



<p>Let&#8217;s make this more interesting.</p>



<p>Let&#8217;s do this.</p>



<p>I&#8217;m going to do auto a equals s dot top.</p>



<p>So I&#8217;m going to grab a value without actually removing it.</p>



<p>Okay.</p>



<p>So more interesting.</p>



<p>So we push the 8 and we push the 2.</p>



<p>So at that point in time, actually let&#8217;s trace this from scratch.</p>



<p>So we have like an empty stack here.</p>



<p>There&#8217;s nothing there.</p>



<p>And we&#8217;re going to push the 8.</p>



<p>So the 8 goes on the very top, just like we did last time.</p>



<p>I&#8217;m going to put an 8 there.</p>



<p>And then we&#8217;re going to push the 2 next.</p>



<p>So the 2 just kind of goes on top.</p>



<p>And then the next line, line 12, we&#8217;re just checking the top.</p>



<p>we&#8217;re allowed to actually look at the top if we want to. So since two is at the top, that means</p>



<p>a is equal to two. I&#8217;m going to put a two here to remind ourselves that a is now equal to two.</p>



<p>Then we&#8217;re going to do a push three. So I&#8217;m just going to stick a three on top of the stack.</p>



<p>And then we&#8217;re going to push a four, four is on top of the stack. Now, again, we&#8217;re not allowed</p>



<p>to look at anything in the middle, anything, anything, but the top. So for example, when the</p>



<p>it and remove it but now that we have a four on top we can no longer even see the three it&#8217;s not</p>



<p>available to us anymore so then we&#8217;re going to pop and put that value into b so um you know what&#8217;s</p>



<p>at the very top it&#8217;s a four so that means we&#8217;re going to actually remove the four and stick that</p>



<p>into b so i&#8217;m going to put four right here to remind ourselves that b is now equal to four</p>



<p>and uh for the purposes of this video you can just imagine that this you know the top of the stack is</p>



<p>of the stack is just totally gone deallocated depending on what implementation you use you</p>



<p>might want to think about crossing it out maybe there&#8217;s like some junk data there now but for the</p>



<p>purposes of this video in this diagram we&#8217;re just saying it&#8217;s gone so it&#8217;s just totally gone</p>



<p>okay then let&#8217;s do another pop so we&#8217;re going to pop and that&#8217;s going to become c so obviously the</p>



<p>top is uh is now the three so that means the three is going to go into the c variable so here&#8217;s a</p>



<p>c variable so here&#8217;s a three right there then the three gets deallocated</p>



<p>and now the top is the two so then we&#8217;ll push a 15 and we&#8217;ll push a 25 so again we just put those</p>



<p>new items on top of the stack even if there was stuff uh there before it&#8217;s gone now so we&#8217;re just</p>



<p>be a 15 and a 25 on top of the stack so we got this and then 25 and then we&#8217;re done adding our</p>



<p>stuff so uh the other functions that we talked about are empty and size uh at the very beginning</p>



<p>when we had just an empty stack like that if we were to call on the empty function it would tell</p>



<p>us true the stack is empty and then every step after that where we had some data in the stack</p>



<p>data in the stack like as soon as we even added that eight at the very beginning from that point</p>



<p>forward then empty would have returned false to us saying no the stack is uh it&#8217;s not empty</p>



<p>the size would have changed uh during every step of the way so you know at line 10 the size would</p>



<p>have been one after we&#8217;re finished with line 10 after line 11 the size would have been 2. 12</p>



<p>wouldn&#8217;t have changed the size so it still would have been 2. 13 would have upgraded the size to</p>



<p>have upgraded the size to four once we popped after that pop was finished it would have been</p>



<p>three again then the second pop would have brought it back down to two and then those two pushes</p>



<p>would have put it back up to three and then four and so then the final size whoops that was horrible</p>



<p>the final size of the stack is four and you can tell that there&#8217;s just four items</p>



<p>another way to double check yourself if you&#8217;re kind of trying to trace this on your own is just</p>



<p>count the number of pushes and subtract the number of pops so how many pushes do we have one two three</p>



<p>2, 3, 4, 5, 6.</p>



<p>So that&#8217;s like 6 minus however many pops we saw.</p>



<p>We see 2 pops.</p>



<p>So 6 minus 2 is equal to 4.</p>



<p>So, you know, when you&#8217;re writing this sort of thing down on,</p>



<p>like as a diagram to practice,</p>



<p>then you know it&#8217;s a 4 just by looking.</p>



<p>But what if you did something wrong?</p>



<p>It&#8217;s a great idea to double check yourself at all times.</p>



<p>So 6 minus 2 is 4.</p>



<p>So we know that the size of the stack is 4.</p>



<p>Looks pretty good.</p>



<p>Looks pretty good and we know the values of A, B, and C and you know one of those was</p>



<p>top two of those were pops.</p>



<p>And yeah, okay.</p>



<p>So notice something though that&#8217;s kind of peculiar about the data that came out.</p>



<p>If we added the data, like I guess while we were adding the data, we added first an eight</p>



<p>and then a two and then a three and then a four.</p>



<p>I&#8217;m just looking at the pushes right now and then a 15 and then a 25, right?</p>



<p>So we added the data in that order.</p>



<p>order. But then when we grab the data out, let me put this in, but maybe like a red bracket</p>



<p>or something. When we grab data out of it, the pops and the tops gave us two and then</p>



<p>a, okay, nevermind. That was not a pop. It gave us a four and then a three if we&#8217;re just</p>



<p>look at the, look at the first two items. Sorry, sorry, sorry. Look at the last two items right</p>



<p>before, and I didn&#8217;t draw this very well. Imagine that we had just pushed the eight and the two and</p>



<p>the three and the four only forget about these other pieces of data. So at this point, when we</p>



<p>start calling our pops, we have only an eight, two, three, four stack, right? So the data that</p>



<p>has a four and then a three if we&#8217;re removing data from the stack.</p>



<p>So notice how the four and the three are backwards.</p>



<p>Notice also like if we kept popping out data, you know, we got the four and then we got</p>



<p>the three, the next, what&#8217;s the next thing that would come out?</p>



<p>It would be the 25, right?</p>



<p>And then it would be the 15.</p>



<p>And then it would be the two.</p>



<p>And then it would be the eight.</p>



<p>So if you really think about it, the stack is reversing our input data.</p>



<p>We added a three and then a four, but we received a four and then a three.</p>



<p>And of course, it&#8217;s a little bit muddled because we have some pushes in between some tops and pops and stuff.</p>



<p>But just looking at what goes into the stack, it&#8217;s backwards, right?</p>



<p>Eight, two, 15, 25.</p>



<p>Let me finish this push sequence up here.</p>



<p>So we added three and four, and then we added a 15.</p>



<p>And then, oh, my penmanship, dude.</p>



<p>shit dude 15 and then we added a 25 so if you look at the data that comes out this is like a 15 and a</p>



<p>25 backwards and then the three and the four are backwards and then the two and the eight are also</p>



<p>backwards and so one thing that a stack does is it reverses data let me give you a cleaner example</p>



<p>with no pops in between the pushes just to show you what we&#8217;re talking about a little bit more</p>



<p>bit more clearly okay so i&#8217;m going to do maybe like another code page here whoops do that and</p>



<p>then i&#8217;m going to say got our stack and we&#8217;re just going to push in some data</p>



<p>and then we&#8217;ll just say s.pop and maybe i&#8217;ll just do that however many times</p>



<p>six two three four five six so now just a very quick trace because this is basically the same</p>



<p>intermixed. So I&#8217;m going to do like the bottom of the stack here. And then, well, I mean like an</p>



<p>empty stack. That&#8217;s not really a bottom of a stack. So we&#8217;re going to push an eight.</p>



<p>And then we&#8217;re going to push a two. And then we&#8217;re going to push a three. And then we&#8217;re</p>



<p>going to push a four. Then a 15. Got to work on my fives, dude. Okay. And then 25.</p>



<p>Okay, one more time.</p>



<p>Oh yeah, I guess I got to slow down.</p>



<p>So what&#8217;s going to come out?</p>



<p>Remember the top is the only place that will give us data.</p>



<p>So if we start popping all these one by one, we&#8217;re going to end up with a 25 for that first</p>



<p>pop.</p>



<p>Maybe I should write it down over here.</p>



<p>Do like a 25 and maybe I&#8217;ll add some line breaks in the code here so that it&#8217;s easier</p>



<p>for me to write with a pen.</p>



<p>Do this and that.</p>



<p>Okay, so the 25, I&#8217;m just going to do a red line through it to designate or to denote</p>



<p>deallocation or just like gone-ness.</p>



<p>Then the top is at the 15.</p>



<p>We do another pop.</p>



<p>It&#8217;s going to be 15.</p>



<p>Oh, I did my first perfect five today.</p>



<p>And then the top of the stack is now at the four.</p>



<p>So then the four is going to pop out next.</p>



<p>And then the three is going to pop out next.</p>



<p>The top is now at the three.</p>



<p>the three so the three is coming out for that pop we deallocate the three the top goes down one and</p>



<p>then we pop it becomes the two that&#8217;s deallocated now and then we grab the eight because that&#8217;s</p>



<p>where the top is so now we&#8217;ve grabbed all of our data out and I just want you to look at this one</p>



<p>more time notice the data is eight that the data that went in was eight two three four fifteen twenty</p>



<p>The data that came out was backwards 25, 15, 4, 3, 2, 8 or 8, 2, 3, 4, 15, 25.</p>



<p>If you kind of like look up.</p>



<p>So a stack is a data reverser.</p>



<p>A stack is also known as something called a, let&#8217;s see,</p>



<p>last in first out data structure, LIFO,</p>



<p>or first in last out, phylo data structure.</p>



<p>What that basically means is just it&#8217;s reversing the data or priority goes to the item that is the youngest.</p>



<p>So if you looked at the stack at the point where we were about to remove the 25,</p>



<p>25 was the most recently added or the youngest item or the item with, I guess, the timestamp, the furthest in the future,</p>



<p>however you want to look at it.</p>



<p>And that&#8217;s the item that came out.</p>



<p>So if you think about it, it was the last item in.</p>



<p>And therefore, when we did another pop, it was the first item out.</p>



<p>So LIFO or PHILO.</p>



<p>and uh you know this eight down here that was obviously the last item that we were able to grab</p>



<p>out of it so when we said you know hop our final pop before the stack became empty uh the eight was</p>



<p>definitely the first item in so first in was the last out if you really want to you can kind of like</p>



<p>jumble these uh these acronyms uh i think most like people just use lipo or phylo</p>



<p>life if you say something to me that I understand I think it&#8217;s probably fine</p>



<p>but it&#8217;s it&#8217;s non-standard I like to say you know foley first out last in that</p>



<p>definitely makes sense it&#8217;s just not very common another thing that I like to</p>



<p>do for fun is also I&#8217;ll mix up the phylo and I&#8217;ll say lo-fi because last out is</p>



<p>first in and now I&#8217;m cooler than other computer people because I use the word</p>



<p>lo-fi I&#8217;ve now got like a giant mustache and like a little like swap meet shirt</p>



<p>like swap meat shirt and I have craft beers and I have work boots on and I&#8217;d</p>



<p>roll up my jeans and my, my, my, my, my sleeves are rolled up and all that stuff.</p>



<p>You know what I&#8217;m saying?</p>



<p>I&#8217;m cooler than everybody else now because I used loaf pie anyway.</p>



<p>So we used integers.</p>



<p>It&#8217;s just important to understand that in modern coding,</p>



<p>I think I might&#8217;ve mentioned this before with the T&#8217;s,</p>



<p>these stacks are templated data structures,</p>



<p>we can hold another data type besides integers as long as we declare what the stack will hold in</p>



<p>advance. So instead of integers, you could imagine there&#8217;s like a custom class, like my class,</p>



<p>every single, you know, item in the stack is actually a full instance of a my class object,</p>



<p>or, you know, floats or strings or just, you know, any data structure you want,</p>



<p>you could put another data structure inside of a stack. People do that sometimes just for fun,</p>



<p>sometimes just for fun you could take a vector and stick it inside of a stack a list put it inside</p>



<p>of a stack you know whatever you want to do just to show that you understand everything</p>



<p>um so again by the way the stack is empty if we tried to pop from it at this point</p>



<p>this would be called a stack underflow we would probably want to throw an exception at the user</p>



<p>or just say we&#8217;re not allowed to do it let&#8217;s see um so i guess now i should tell you some</p>



<p>common uses for stacks i&#8217;m looking at my notes right here uh obviously our stack has reversed</p>



<p>has reversed the data. So stacks are kind of good for data reversing. Imagine if you had like a word</p>



<p>and you wanted to detect if the word was a palindrome or not, you would just like put all</p>



<p>the letters of the word into your stack and then grab them back out and see if the word was still</p>



<p>in the same order. If it was, then your word was probably a palindrome. If you don&#8217;t remember what</p>



<p>a palindrome is, I&#8217;m going to write down the word radar in reverse from backwards, from back to</p>



<p>front, right? It&#8217;s the same word. So that&#8217;s a palindrome. You could also use stacks kind of</p>



<p>as a trail of breadcrumbs. Like you could imagine that early implementations of browsers</p>



<p>had your browsing history in a stack somewhere so that every time you visited a webpage, then</p>



<p>some kind of block of information, maybe like a custom class instance was put onto a stack</p>



<p>somewhere and it contained information about like when you visited the webpage, what the URL was,</p>



<p>it is that the browser wants to remember and then later when you hit the back button then you can</p>



<p>imagine the browser is popping from the stack in order to go backwards in your history or your</p>



<p>spotify playlist or whatever it is you&#8217;re doing honestly you know these systems are much more</p>



<p>advanced than just using you know vanilla stacks now but you could imagine doing something on your</p>



<p>own for fun or just what it might have been like in the very beginning i&#8217;m going to erase fully</p>



<p>because that&#8217;s just that&#8217;s just that&#8217;s just cringe lo-fi i think is way cooler um so trail of bread</p>



<p>So a trail of breadcrumbs, like browser history, you could also imagine undo history, like</p>



<p>if you had a, I don&#8217;t know, like a text editor of some sort or like a image editor of some</p>



<p>sort, every major change that you did to it, maybe the program under the hood is adding</p>



<p>your change to the stack.</p>



<p>And that makes it easier to sort of reverse your changes as those changes are popped.</p>



<p>And there&#8217;s like a sort of mathematical uses like balancing parentheses and things, but</p>



<p>balancing parentheses and things, but I&#8217;m not going to talk about that too much.</p>



<p>And one of the most important uses for stacks inside of your computer is actually the call</p>



<p>stack. I&#8217;m going to talk about that in a future video. But again, remember each, you know, little</p>



<p>item on the stack, it could be a different data structure on its own. It doesn&#8217;t have to be an</p>



<p>integer. So imagine that I bundled up a bunch of information about a function call, and I called it</p>



<p>I just stuck a call frame on the stack.</p>



<p>That&#8217;s basically the call stack.</p>



<p>But that&#8217;s for another video.</p>



<p>Anyway, so let&#8217;s see.</p>



<p>Is there anything else that I wanted to show you?</p>



<p>I think we&#8217;re actually done just talking about the basics of stacks.</p>



<p>I&#8217;m not talking about time complexities or anything like that in this video.</p>



<p>Check a future video if you&#8217;re interested in time complexities per certain implementations</p>



<p>and so forth.</p>



<p>But for now, this is how a stack works.</p>



<p>or LIFO or LOFI data structure.</p>



<p>Nobody&#8217;s going to say LOFI but me, just FYI.</p>



<p>But maybe everybody will start doing it now.</p>



<p>I don&#8217;t know.</p>



<p>If it becomes a trend, okay?</p>



<p>You heard it here first.</p>



<p>Give everybody this link.</p>



<p>All right, I hope you feel like an expert on stacks</p>



<p>at this point.</p>



<p>I hope you had a little bit of fun</p>



<p>and learned a little bit of something, some stuffs.</p>



<p>I&#8217;ll see you in the next video.</p>



<p>hey everybody thanks for watching this video again from the bottom of my heart I really</p>



<p>appreciate it I do hope you did learn something and have some fun if you could do me a please a</p>



<p>small little favor could you please subscribe and follow this channel or these videos or whatever it</p>



<p>is you do on the current social media website that you&#8217;re looking at right now it would really mean</p>



<p>the world to me and it&#8217;ll help make more videos and grow this community so we&#8217;ll be able to do</p>



<p>videos, longer videos, better videos, or just I&#8217;ll be able to keep making videos in general. So please</p>



<p>do me a kindness and subscribe. You know, sometimes I&#8217;m sleeping in the middle of the night</p>



<p>and I just wake up because I know somebody subscribed or followed. It just wakes me up</p>



<p>and I get filled with joy. That&#8217;s exactly what happens every single time. So you could do it as</p>



<p>a nice favor to me or you could you could troll me if you want to just wake me up in the middle</p>



<p>of the night, just subscribe and then I&#8217;ll just wake up. I promise that&#8217;s what will happen.</p>



<p>Also, if you look at the middle of the screen right now, you should see a QR code which you can scan in order to go to the website</p>



<p>which I think is also named somewhere at the bottom of this video and</p>



<p>It&#8217;ll take you to my main website where you can just kind of like see all the videos</p>



<p>I published and the services and tutorials and things that I offer and all that good stuff and</p>



<p>If you have a suggestion for</p>



<p>Clarifications or errata or just future videos that you want to see</p>



<p>please leave a comment or if you just want to say hey what&#8217;s up what&#8217;s going on you know just send</p>



<p>me a comment whatever i also wake up for those in the middle of the night i get i wake up in a cold</p>



<p>sweat and i&#8217;m like it would really it really mean the world to me i would really appreciate it so</p>



<p>again thank you so much for watching this video and um enjoy the cool music</p>



<p>as as i fade into the darkness which is coming for us all</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/master-stacks-fun-guide-to-data-structures-lifo-real-world-uses/">Master Stacks: Fun Guide to Data Structures, LIFO &amp; Real-World Uses</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/master-stacks-fun-guide-to-data-structures-lifo-real-world-uses/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Master Bitwise Operators: OR, AND, NOT, XOR, NOR for Beginners</title>
		<link>https://www.NeuralLantern.com/master-bitwise-operators-or-and-not-xor-nor-for-beginners/</link>
					<comments>https://www.NeuralLantern.com/master-bitwise-operators-or-and-not-xor-nor-for-beginners/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Mon, 30 Jun 2025 06:15:25 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[AND operator]]></category>
		<category><![CDATA[binary logic]]></category>
		<category><![CDATA[binary operations]]></category>
		<category><![CDATA[bit manipulation]]></category>
		<category><![CDATA[bitwise operators]]></category>
		<category><![CDATA[C programming]]></category>
		<category><![CDATA[coding for beginners]]></category>
		<category><![CDATA[coding tips]]></category>
		<category><![CDATA[computer science basics]]></category>
		<category><![CDATA[NOR operator]]></category>
		<category><![CDATA[NOT operator]]></category>
		<category><![CDATA[OR operator]]></category>
		<category><![CDATA[programming tutorial]]></category>
		<category><![CDATA[tech tutorials]]></category>
		<category><![CDATA[XOR operator]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=173</guid>

					<description><![CDATA[<p>Learn bitwise operators (OR, AND, NOT, XOR, NOR) with clear examples. Perfect for beginners mastering binary logic in programming.</p>
<p>The post <a href="https://www.NeuralLantern.com/master-bitwise-operators-or-and-not-xor-nor-for-beginners/">Master Bitwise Operators: OR, AND, NOT, XOR, NOR for Beginners</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Master Bitwise Operators: OR, AND, NOT, XOR, NOR for Beginners" width="1380" height="776" src="https://www.youtube.com/embed/mL_wTRllqtc?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Want to understand bitwise operators? This video dives into OR, AND, NOT, XOR, and NOR with easy-to-follow examples. Learn how to use these operators for flags, masks, and more in programming. Perfect for beginners or anyone wanting to master binary logic in C or other languages. I break it down with real examples, a touch of humor, and no fluff. Subscribe for more coding tutorials, and check out my site for extra resources. Drop a comment with your questions or video ideas!</p>



<p>Introduction to Logical Operators 00:00:00<br>Explanation of Bitwise OR 00:00:35<br>OR Operation Examples 00:01:01<br>Bitwise OR with Multiple Bits 00:02:12<br>Using OR for Flags 00:03:52<br>Introduction to Logical AND 00:08:06<br>AND Operation Examples 00:08:29<br>Using AND as a Mask 00:10:00<br>Checking Specific Bits with AND 00:11:17<br>Introduction to NOT Operation 00:13:36<br>Introduction to NOR Operation 00:14:38<br>Introduction to XOR Operation 00:16:37<br>XOR and Neural Networks 00:16:53<br>Conclusion and Call to Action 00:18:38</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hey everybody! In this video I&#8217;m going to talk about basic logical operators such as OR and AND.</p>



<p>Uh so let&#8217;s let&#8217;s dive right into it. What am I talking about with the OR and AND?</p>



<p>Suppose for the sake of argument that this notepad is totally dark and I wanted it to be really light</p>



<p>and then I have to go into the system settings to fix it. Sorry let me change my theme.</p>



<p>How about that?</p>



<p>Okay.</p>



<p>So suppose for the sake of argument, we&#8217;ve got, you know, a couple of bits.</p>



<p>These are going to be a bitwise operations for the most part.</p>



<p>In other languages, sometimes we will say logical operator, but actually we&#8217;re just</p>



<p>talking about values rather than bits individually.</p>



<p>So these are bitwise operators.</p>



<p>Imagine we have like a couple of bits.</p>



<p>Remember the possible values for bits are just, you know, a zero and a one binary.</p>



<p>So suppose we have a couple of values.</p>



<p>values, let&#8217;s say we have a zero here and a one.</p>



<p>So if I apply a logical or to the zero and the one,</p>



<p>the result is going to be a one because either the first bit or the second bit are a one.</p>



<p>You could also expand these operators to have multiple sets of bits,</p>



<p>but we&#8217;re just going to do, you know, one set against another set.</p>



<p>In this case, each set is just one bit long, but we&#8217;ll do, we&#8217;ll do a more complicated stuff in a minute.</p>



<p>If I have a zero and a one, then the answer there is, well, let me just put or maybe.</p>



<p>The answer is a one.</p>



<p>I&#8217;ll put or maybe at the top, just like or to let you know that we&#8217;re doing ors here</p>



<p>on the top.</p>



<p>So if we have a zero and a one, the answer is going to be a one.</p>



<p>If we have a one and a zero, the answer is going to be a one.</p>



<p>Also, if we have two ones, which looks like an L over there, I got to work on my penmanship.</p>



<p>Then the answer is also going to be a one.</p>



<p>if either of the bits in question are a one then the answer should be a one. The only case with an</p>



<p>OR that results in a zero is if both of the bits are zero because neither the first or the second</p>



<p>are actually a one right so this is the basic idea of using an OR operator and you can also do this</p>



<p>with multiple bits at the same time like for example we could say let&#8217;s take a bunch of random</p>



<p>work on the it&#8217;s the pressure dude the l&#8217;s are driving me crazy okay oh my god okay so i do that</p>



<p>and i let go okay i&#8217;m just going to put some random bits uh underneath the the first set of</p>



<p>random bits put like a zero here and then like a one here maybe and we&#8217;ll say that we&#8217;re going to</p>



<p>do a logical or just like you might think of doing a you know addition or subtraction we&#8217;ll just say</p>



<p>you know, addition or subtraction. We&#8217;ll just say we&#8217;re going to or these two sets of bits.</p>



<p>Actually, these are six on the top and six on the bottom. If I add two more, then it&#8217;ll be a nice</p>



<p>little bite for the top and the bottom. So I&#8217;m just going to do that, you know, to have eight</p>



<p>bits on the top and eight bits on the bottom. Okay. So if I just want to logically or two sets</p>



<p>of bits, literally, I just have to do one pair of bits at a time. So a one or zero is just a one.</p>



<p>One or zero is just a one, a zero or one is a one, a one or zero is a one, a zero or one</p>



<p>is a one.</p>



<p>And then these ones, everything is just a one.</p>



<p>Okay.</p>



<p>So that was too easy.</p>



<p>Maybe if I, I don&#8217;t know, maybe if I change one of these ones to a zero, then we would</p>



<p>actually be able to have a zero somewhere in here.</p>



<p>So that&#8217;s a logical or a bitwise or operator or operation.</p>



<p>So you can, you can kind of use this in various ways.</p>



<p>can kind of use this in various ways i mean obviously if you want to manipulate some bits</p>



<p>this can be pretty useful inside of the machine but there was kind of an old school way that</p>



<p>people did flags with arguments they would basically say something like this they would go</p>



<p>in their computer program they would say you know flag a name it something like turn on the display</p>



<p>or enable caching or just like whatever right so we&#8217;ll just have a flag we&#8217;ll call it flag a</p>



<p>that value is equal to a one and then maybe flag b its value is equal to a two and then flag c</p>



<p>its value would be a four and then we basically just double the value of the flag and the reason</p>



<p>for that c d e f i&#8217;ll just stop with f maybe oh wait that was supposed to be 16 and that&#8217;s 32.</p>



<p>the reason for that is if you double the value of each flag so that uh</p>



<p>and then you can do a bitwise or against all of these flags and sort of combine multiple flags.</p>



<p>Because if you think about it, if we&#8217;re talking about binary,</p>



<p>if we suppose this is just a regular eight bit number, then, you know, the first bit has a</p>



<p>strength of one. If you&#8217;ve seen my other videos for converting between binary and hex,</p>



<p>the second bit has a strength of two. The next bit has a strength of four and then eight and</p>



<p>and then 32 and 64 and then 128.</p>



<p>And so if you look at the flags,</p>



<p>1, 2, 4, 8, 16, 32,</p>



<p>they map to only one bit.</p>



<p>It&#8217;s not going to be some kind of random pattern for these numbers.</p>



<p>It&#8217;s literally going to be flag A is going to look like this.</p>



<p>1, 2, 3, 4, 5, 6, 7, 8.</p>



<p>And then flag B is going to look like this.</p>



<p>1, 2, 3, 4, 5, 6, 7, 8.</p>



<p>five, six, seven, eight. And flag D is going to look like this. Whoops. Let me make that green.</p>



<p>Still getting used to this. Oh, sorry. C is the next one. One, two, three, four, five,</p>



<p>six, seven, eight. Can you see the pattern here? Let me just do D and be done with it at this</p>



<p>point. One, two, three, four, five, six, seven, eight. So because we&#8217;re increasing the value of</p>



<p>the flags by a power of two, or by a power of two, they&#8217;ll always correspond to just one bit.</p>



<p>they&#8217;ll always correspond to just one bit, which means if you apply a logical or operation,</p>



<p>you can represent a bunch of different flags with just one number.</p>



<p>Think about this.</p>



<p>What if I wanted to have, oh, I don&#8217;t know.</p>



<p>Let me erase this.</p>



<p>What if I wanted to have some, let&#8217;s say I wanted flag A and flag D and flag F just for</p>



<p>the sake of argument.</p>



<p>Dang, this pen.</p>



<p>It&#8217;s actually my fault completely, but I need to practice.</p>



<p>but I need to practice F okay and DNF so that would basically be you know 1 2 3 4 5 6 7 8</p>



<p>and then D would be the 8 so a 1 0 0 0 there and then a bunch of zeros elsewhere and then the F</p>



<p>So if we did an OR between all of those, then the OR is just basically 00101001.</p>



<p>And if you convert that from binary to decimal, what is that?</p>



<p>That&#8217;s a 1248 plus 8 plus 1248 and then a 32.</p>



<p>So 41.</p>



<p>just write down the number 41 and if the programmer is smart enough to you know parse all the bits</p>



<p>and everything then they&#8217;ll know that you have flags a and d and f set that&#8217;s not necessarily</p>



<p>something that all the modern programs do anymore it was much more popular in the olden days but i</p>



<p>think some people still kind of do it especially if they&#8217;re programming in c and other languages</p>



<p>where they want speed it&#8217;s pretty fast to look at bits inside of the machine so keep that in mind</p>



<p>Keep that in mind now we know how to do an OR operation and we know one reason that it might be useful and</p>



<p>Yeah, okay. I&#8217;m gonna move on to the next operation</p>



<p>So clearing the screen now</p>



<p>Hello little doggy he barked and now he&#8217;s in the room</p>



<p>Let&#8217;s do</p>



<p>The logical AND operation okay, so suppose we have two bits here</p>



<p>in a one only if both of the input bits are a one i&#8217;m gonna whoops i accidentally cleared the whole</p>



<p>entire thing let me forget where my red pen is okay and okay so if we have a zero and a zero</p>



<p>the result is zero because neither of those are a one if we have a zero and a one the result is</p>



<p>still going to be zero because we need both bits to be a one to result in a one so then that means</p>



<p>would also result in a zero. So you get a bunch of zeros until finally you have an input pattern</p>



<p>that is just two ones. And then finally the result is one. So that&#8217;s a logical and.</p>



<p>Let me do a quick example so we can and a bunch of bits together. I&#8217;m just going to do more</p>



<p>random bit patterns. So there&#8217;s another L there. I&#8217;m cringing. I&#8217;m self-cringing. One, two, three,</p>



<p>okay so then i&#8217;ll do like another one there and like a zero there and a zero maybe a couple of</p>



<p>ones maybe three ones and then a zero and then one i guess and we&#8217;ll just say that we&#8217;re going</p>



<p>to end those together so and oh man i&#8217;m mixing uppercase and lowercase like crazy</p>



<p>so uh to end them together you know that bit position right here that&#8217;s going to be a one</p>



<p>and then we have a zero because they don&#8217;t match they&#8217;re not both one and then we have another zero</p>



<p>a one and then we have a zero and a zero and a zero and a one so this is a logical and you can</p>



<p>use logical ands for a wide variety of things but one thing you can kind of do somewhat easily is to</p>



<p>use one number as a mask against another number for example notice how uh suppose this was the</p>



<p>input number let&#8217;s just say we have the input number up top and maybe you wanted to make sure</p>



<p>because you&#8217;re you&#8217;re checking for those bits individually or maybe you want to just prevent</p>



<p>the input from having certain bits on for some other reason well you can you can apply the mask</p>



<p>as the second bit and use a logical and i&#8217;ll say mask here sorry you can apply a mask as the second</p>



<p>bit pattern and notice how in the answer there are only ones where both you know the input and</p>



<p>means if I wanted to just control only which ones are allowed I can use the mask notice how the mask</p>



<p>has ones in these positions and there are definitely no zeros sorry there are definitely</p>



<p>no ones in any position where a mask had a zero so the mask can kind of like you know mute or mask</p>



<p>or control the input pattern if that makes sense hopefully another thing we could do if we wanted</p>



<p>if one bit exists. Let me go ahead and clear this real fast. I&#8217;m going to just do maybe four</p>



<p>bits this time. So we could obviously do an and against four zeros, and this would result in just,</p>



<p>you know, a resulting pattern of zero. So this is not super useful. The result would just</p>



<p>definitely be four zeros. But notice again how the second pattern is sort of controlling what&#8217;s</p>



<p>allowed to go through from the first pattern. Suppose I wanted to check to see if that particular</p>



<p>particular bit was on or off.</p>



<p>All I have to do is mask it with a one in the correct pattern.</p>



<p>So, you know, the second bit that I just wrote down on the bottom row,</p>



<p>I just want to see if that second bit is on or off in the input pattern.</p>



<p>I don&#8217;t care about any of the other bits.</p>



<p>That means the result will be this.</p>



<p>So now it&#8217;s much more easy for me to see if that bit is on.</p>



<p>I could just compare the value of those bits to a regular integer.</p>



<p>Like, for example, if we consider that this was the one and this was the two</p>



<p>considered that this was the one and this was the two and this was the four or sorry four and then</p>



<p>the eight I could just ask now if the final value equals two and then I would know if that bit was</p>



<p>on or not in the original pattern and so if I wanted to check to see if this other you know</p>



<p>bit was on I can move this over here and set that back to a zero so the resulting pattern would be</p>



<p>zeros then I&#8217;d ask myself is the resulting value equal to four no it&#8217;s equal to zero and so then</p>



<p>Another thing you can do that I&#8217;m going to talk about in a future video is just sort of shift the bits over.</p>



<p>You could, instead of checking to see if the value was a 4 or like a direct integer,</p>



<p>you could just sort of shift over a certain number of spots and then check to see if it was equal to 1 or 0.</p>



<p>Let me put this 1 back over into its original position just so that we&#8217;ll have something that had a 1.</p>



<p>is one from uh you know the right side if it&#8217;s one to the left from the right side</p>



<p>then i could just shift all the bits one to the right and end up with a pattern that is zero zero</p>



<p>zero one i&#8217;m not going to talk about bit shifting operations in this video but just know that you can</p>



<p>and you&#8217;ll see more of it in a future video so then you know this is another way to check to</p>



<p>see if a bit was on first you do a mask for that bit and then you shift bits and then you just</p>



<p>check to see if the final value is a zero or one which may or may not feel easier than checking for</p>



<p>or may not feel easier than checking for an actual integer in your program.</p>



<p>Okay, so we&#8217;ve done OR and also AND. The next bit pattern is called a NOT, which is really easy.</p>



<p>It&#8217;s literally just an inversion of the original bit pattern. So for the NOT, we don&#8217;t really take</p>



<p>two bits against each other. We just take an input bit and we just invert it. We&#8217;ll just say</p>



<p>So that&#8217;s a knot. Pretty easy. We could also knot, you know, a random bit pattern with Ls.</p>



<p>So I swear, somebody&#8217;s going to show up and this is their first computer science video.</p>



<p>They&#8217;re going to go tell their parents, hey, there&#8217;s Ls in computer science.</p>



<p>So sorry. I&#8217;m so sorry. Okay. So I got four there. So if I knot those, then that&#8217;s pretty easy.</p>



<p>It&#8217;s just going to be the opposite, you know, an inversion.</p>



<p>you know, an inversion.</p>



<p>One, zero, one, zero.</p>



<p>Let me just double check that I did that correctly.</p>



<p>Yeah, so that&#8217;s the knot pattern.</p>



<p>No big deal.</p>



<p>Pretty easy.</p>



<p>So then maybe the next thing that we can talk about is the nor,</p>



<p>which just means not or.</p>



<p>So let me draw that out real fast just to show you what I&#8217;m talking about.</p>



<p>So if we do nor, pretty much you can imagine first taking the or and then knotting it.</p>



<p>So inverting the or.</p>



<p>the OR. So for example, if we have two bits here, actually, let me, let me do, let me do a</p>



<p>sequential counter. Cause I think that&#8217;s more fun. I&#8217;m counting right now from one to a three</p>



<p>or a actually, I do that in the last one. I started with zero. I hope let&#8217;s count from zero</p>



<p>to three. So zero and then one and then two and then three. So I&#8217;m counting in binary.</p>



<p>two input bits and we&#8217;re going to do a nor then the first thing we probably want to do is take</p>



<p>the or operator so that would be a zero here i&#8217;ll just put or in parentheses just to let you know</p>



<p>that this is kind of a nice first step you could memorize nor if you wanted to but i don&#8217;t i don&#8217;t</p>



<p>really remember how to do it without doing these steps so uh it&#8217;s going to be ones for everything</p>



<p>else because in the or you get a one if either of those is a one and then uh the next step is you</p>



<p>the or i&#8217;ll just put nor here just to let you well just to let you know that you&#8217;re uh well i</p>



<p>don&#8217;t know if i put nor then it kind of sounds like i&#8217;m norring that one bit doesn&#8217;t it so maybe</p>



<p>here i&#8217;ll say uh not just to let you know that this is just one step against the previous bit</p>



<p>so the knot is uh just going to be an inversion and so the nor of zero zero is one the nor of zero</p>



<p>nor of 1 1 is 0 and that&#8217;s how you do a nor and all of these logical or bitwise</p>



<p>operators can be used in circuits and circuit design and just you know other</p>



<p>types of logical operations I&#8217;m gonna move on let&#8217;s see the next one is gonna</p>



<p>be XOR that I wanted to talk about in this video so what is XOR it just means</p>



<p>exclusive or so it&#8217;s a little bit more complicated than or this is actually a</p>



<p>one because it has a history with neural networks. When you have a neural network that does not have</p>



<p>more than one, or sorry, if you have a neural network that does not have any hidden layers,</p>



<p>like if you just have an input layer and an output layer, then the neural network should</p>



<p>actually not be able to solve XOR. It should not be able to learn it. You have to increase the</p>



<p>topology of the neural network in some way, make it a little bit more complicated. For example,</p>



<p>one or more middle layers between the input and the output layers. If you understand neural</p>



<p>networks, it&#8217;s just kind of fun to know, oh, XOR stumps a shallow network and kind of starts to</p>



<p>prove that deep networks might be a little bit smarter or deepish at least. Okay. So XOR,</p>



<p>let&#8217;s start off by counting here. I&#8217;m going to do zero and zero, and then this is the number one,</p>



<p>and this is the number two, and this is the number three. And exclusive OR just basically means</p>



<p>just basically means an or but if both of the bits are one then it&#8217;s a zero so that means</p>



<p>either of the bits can be a one to produce a one but it must be exclusive the bit that is a one</p>



<p>can&#8217;t also be next to another bit that&#8217;s a one so let me show you so in is in a double zero</p>



<p>the answer is just going to be a zero in a zero and one the answer is going to be a one in a one</p>



<p>exclusive, the one is it has a, it has a buddy or a partner.</p>



<p>It&#8217;s not an exclusive one.</p>



<p>So we&#8217;ll say that that&#8217;s a zero.</p>



<p>So that&#8217;s the XOR.</p>



<p>I don&#8217;t know.</p>



<p>You could put like a, a, a not on top of that or an and on top of that or whatever</p>



<p>you wanted to do.</p>



<p>And we can make stuff that&#8217;s a lot more complicated, but these are the basics of</p>



<p>or and not XOR and NOR as bitwise operators.</p>



<p>So thank you for watching this video.</p>



<p>That&#8217;s all I have to say for now.</p>



<p>See you in the next one.</p>



<p>Hope you learned a little bit and had a little bit of fun.</p>



<p>I&#8217;m out.</p>



<p>social media website that you&#8217;re looking at right now it would really mean the world to me and it&#8217;ll</p>



<p>help make more videos and grow this community so we&#8217;ll be able to do more videos longer videos</p>



<p>better videos or just i&#8217;ll be able to keep making videos in general so please do do me a kindness</p>



<p>and uh and subscribe you know sometimes i&#8217;m sleeping in the middle of the night and i just</p>



<p>wake up because i know somebody subscribed or followed it just wakes me up and i get filled</p>



<p>with joy that&#8217;s exactly what happens every single time so you could do it as a nice favor to me or</p>



<p>it as a nice favor to me or you could you could troll me if you want to just wake me up in the</p>



<p>middle of the night just subscribe and then i&#8217;ll i&#8217;ll just wake up i promise that&#8217;s what will</p>



<p>happen also uh if you look at the middle of the screen right now you should see a qr code which</p>



<p>you can scan in order to go to the website which i think is also named somewhere at the bottom of</p>



<p>this video and it&#8217;ll take you to my main website where you can just kind of like see all the videos</p>



<p>i published and the services and tutorials and things that i offer and all that good stuff and</p>



<p>if you have a suggestion for uh uh clarifications or errata or just future videos that you want to</p>



<p>see please leave a comment or if you just want to say hey what&#8217;s up what&#8217;s going on you know</p>



<p>just send me a comment whatever i also wake up for those in the middle of the night i get i wake up</p>



<p>in a cold sweat and i&#8217;m like it would really it really mean the world to me i would really</p>



<p>appreciate it so again thank you so much for watching this video and um enjoy the cool music</p>



<p>the cool music as I fade into the darkness which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/master-bitwise-operators-or-and-not-xor-nor-for-beginners/">Master Bitwise Operators: OR, AND, NOT, XOR, NOR for Beginners</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/master-bitwise-operators-or-and-not-xor-nor-for-beginners/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>DDD Debugger Tutorial: Fast Guide to Debugging C++ &#038; C Code</title>
		<link>https://www.NeuralLantern.com/ddd-debugger-tutorial-fast-guide-to-debugging-c-c-code/</link>
					<comments>https://www.NeuralLantern.com/ddd-debugger-tutorial-fast-guide-to-debugging-c-c-code/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 22 Jun 2025 13:42:41 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[C debugging]]></category>
		<category><![CDATA[c++ debugging]]></category>
		<category><![CDATA[coding for beginners]]></category>
		<category><![CDATA[Data Display Debugger]]></category>
		<category><![CDATA[DDD debugger]]></category>
		<category><![CDATA[debugger GUI]]></category>
		<category><![CDATA[debugging tutorial]]></category>
		<category><![CDATA[GDB debugger]]></category>
		<category><![CDATA[learn to code]]></category>
		<category><![CDATA[programming tips]]></category>
		<category><![CDATA[programming tutorial]]></category>
		<category><![CDATA[set breakpoints]]></category>
		<category><![CDATA[software debugging]]></category>
		<category><![CDATA[source code debugging]]></category>
		<category><![CDATA[Ubuntu debugging]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=161</guid>

					<description><![CDATA[<p>Learn DDD debugging fast! This tutorial covers breakpoints, source code, and GDB console for C++ &#038; C. Watch our GDB video first for better skills!</p>
<p>The post <a href="https://www.NeuralLantern.com/ddd-debugger-tutorial-fast-guide-to-debugging-c-c-code/">DDD Debugger Tutorial: Fast Guide to Debugging C++ &amp; C Code</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="DDD Debugger Tutorial: Fast Guide to Debugging C++ &amp; C Code" width="1380" height="776" src="https://www.youtube.com/embed/jRsoOosxWuc?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Hey coders! Dive into this quick DDD tutorial to learn the Data Display Debugger for C++ and C programs. See how to launch DDD, set breakpoints, view source code, and use the GDB console. I’ll walk you through the basics, but check my GDB video first for a better debugging foundation. If you’re new to GUI debuggers or just curious, this is for you! Subscribe for more programming tips, and let me know in the comments if you want advanced DDD content. Scan the QR code for more tutorials!</p>



<p>Introduction to DDD 00:00:00<br>DDD vs GDB Comparison 00:00:04<br>Installation Instructions 00:00:56<br>Launching DDD 00:01:20<br>Source Code Window 00:01:57<br>Setting Breakpoints 00:03:16<br>Running and Debugging 00:04:08<br>GDB Console Commands 00:04:21<br>Modifying Breakpoints 00:05:20<br>Closing DDD 00:05:36<br>Recommendation to Learn GDB 00:05:48<br>Call to Subscribe 00:06:32<br>Website and Comments 00:07:17</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>DDD debugger, Data Display Debugger, debugging tutorial, C++ debugging, C debugging, GDB debugger, programming tutorial, software debugging, coding for beginners, debugger GUI, set breakpoints, source code debugging, Ubuntu debugging, learn to code, programming tips</p>



<p>hey there in this video i&#8217;m going to give you a very very quick overview</p>



<p>of a program called ddd which you can use to debug your programs</p>



<p>disclaimer you should see my gdb video first before you watch this one because it&#8217;s much more</p>



<p>useful and in my personal opinion gdb is a much better debugger than ddd ddd ddd is actually</p>



<p>over GDB so it doesn&#8217;t really add any more functionality it&#8217;s sort of for</p>



<p>people who like to use GUI&#8217;s but the GUI is not it&#8217;s not very good but it&#8217;s</p>



<p>there if you&#8217;re still struggling with the command line anyway so yeah see my</p>



<p>other video if you want to learn about make files if you want to learn about</p>



<p>C++ C assembly GDB debugging all that stuff are in other videos but assuming</p>



<p>that you know how to use GDB we can start on DDD now DDD anyway if you don&#8217;t</p>



<p>Anyway, if you don&#8217;t have DDD on your system, you can go sudo apt install DDD.</p>



<p>I&#8217;m on Ubuntu.</p>



<p>You could use whatever package manage you have on your system like DNF or whatever.</p>



<p>So sudo apt install DDD.</p>



<p>I don&#8217;t have to do that because I already have it on my system, unfortunately.</p>



<p>Anyway, so the first thing that you can do is you can sort of launch it with DDD up here.</p>



<p>It&#8217;s called the data display debugger.</p>



<p>You can launch it and then you can attach it to your program for me.</p>



<p>attach it to your program for me i like to just launch it uh from the command line i&#8217;ll type ddd</p>



<p>and then the name of my executable i&#8217;ll build my executable real fast again this all this stuff is</p>



<p>in another video how to build and you know what so forth so i&#8217;m going to build my uh executable</p>



<p>and there it is main so i&#8217;m going to go ddd main and this is the uh i can&#8217;t remember the name of</p>



<p>display debugger yeah I don&#8217;t really like to use this anyway you can see that</p>



<p>right away there is a source code window visible which sort of looks at your</p>



<p>program&#8217;s source code if that&#8217;s not visible you can click on the view menu</p>



<p>item up here and start you know enabling and disabling windows there&#8217;s a data</p>



<p>window to let you look at data there&#8217;s a machine code window I&#8217;m just gonna</p>



<p>basically make sure that the GDB console is up and that the source window is up</p>



<p>when I closed both windows hoping that I could show you that I opened both of them it just shut</p>



<p>down the whole program okay anyway so yeah click view and make sure that the source windows open</p>



<p>so we can see our source code and then also make sure that the gdb console window is open so we can</p>



<p>type gdb commands and then um well you know probably if you know gdb you&#8217;ll you&#8217;ll you&#8217;ll</p>



<p>want to start typing commands here you know enter a breakpoint at main.cpp line you know</p>



<p>dot cpp line you know whatever but once you start doing that a lot you&#8217;ll realize maybe you don&#8217;t</p>



<p>need to be inside of ddd with ddd you can right click on a line and add a breakpoint manually so</p>



<p>that&#8217;s a little convenient i think we can do can we do control mouse no there&#8217;s a lot of obscure</p>



<p>areas here well you can go to the preferences and change the font size i think i&#8217;m not going to deal</p>



<p>with that in this video but so suppose for the sake of argument i wanted to break at this line</p>



<p>line right here I could just right click on it and I have to hold down the right</p>



<p>mouse and say set breakpoint and then I could do the same thing for this set</p>



<p>breakpoint and then for this set breakpoint so it&#8217;s a little more</p>



<p>convenient a little bit faster if you like looking at the text in this way to</p>



<p>set breakpoints and then you can disable breakpoints and you can delete breakpoints</p>



<p>and you can reset the execution position if you&#8217;re absolutely sure you know what</p>



<p>know what you&#8217;re doing you can have your program skip an area and jump somewhere and then once</p>



<p>i&#8217;ve kind of set up my break points i can go up here at the top this is the uh i forgot what</p>



<p>window this is called but i can basically hit run which i accidentally already clicked when i was</p>



<p>trying to resize the window there we go oh i can&#8217;t resize it okay so we&#8217;ll go run and uh</p>



<p>well now we&#8217;ve already hit a breakpoint right away notice how at the bottom in the gdb uh</p>



<p>GDB console area it says breakpoint 2 at line 36 and then there&#8217;s a green arrow here letting</p>



<p>us know that we hit one of our breakpoints already so then we can do normal GDB stuff</p>



<p>we can go info breakpoints just to kind of see what&#8217;s in there and you can resize with this</p>



<p>handle on the very right side I don&#8217;t think it works in the middle here I&#8217;ve tried it many times</p>



<p>but so you can kind of resize with this handle on the right side to get more real estate for</p>



<p>panel and so it&#8217;s telling me all right I did info breakpoints just to see the</p>



<p>breakpoints I can go info locals to see my local variables like a print a</p>



<p>variable you know all that all the normal GDB commands I&#8217;m gonna hit</p>



<p>continue and five to skip the next five times this breakpoints get hit this</p>



<p>breakpoint gets hit now the next breakpoint that gets hit is this other</p>



<p>one over here I can do the same thing info locals I can see the state of all</p>



<p>what is b you know what is i what is a what is whatever and when i&#8217;m finished i can say continue</p>



<p>and i can also modify my breakpoints by just sort of like deleting them enabling them disabling them</p>



<p>but that&#8217;s me trying to type everything in the terminal of course with ddd you can right click</p>



<p>on a breakpoint and disable it or delete it and so forth when you&#8217;re eventually done let&#8217;s see</p>



<p>kill the process and then you can just kind of exit DDD at this point or you can exit</p>



<p>the GDB console with Q and that&#8217;s it that&#8217;s the basics for DDD.</p>



<p>However again I strongly encourage you to learn GDB first and by the time you do that</p>



<p>you will probably not want to use DDD.</p>



<p>But I have to put up this video regardless.</p>



<p>Let me know if you&#8217;re interested in very advanced stuff covering DDD.</p>



<p>20 years, I might upload another DDD video. You never know.</p>



<p>Okay, thanks for watching this video.</p>



<p>I hope you learned a little bit, and I hope you go directly to the GDB video after this.</p>



<p>See you in the next one.</p>



<p>Hey everybody, thanks for watching this video again from the bottom of my heart. I really</p>



<p>appreciate it. I do hope you did learn something and have some fun. If you could do me a please,</p>



<p>Could you please subscribe and follow this channel or these videos or whatever it is you do on the current social media</p>



<p>Website that you&#8217;re looking at right now</p>



<p>It would really mean the world to me and it&#8217;ll help make more videos and grow this community</p>



<p>So we&#8217;ll be able to do more videos longer videos better videos or just I&#8217;ll be able to keep making videos in general</p>



<p>So please do do me a kindness and and subscribe</p>



<p>You know sometimes I&#8217;m sleeping in the middle of the night and I just wake up because I know somebody subscribed or followed</p>



<p>subscribed or followed. It just wakes me up and I get filled with joy. That&#8217;s exactly what happens</p>



<p>every single time. So you could do it as a nice favor to me or you could you could troll me if</p>



<p>you want to just wake me up in the middle of the night just subscribe and then I&#8217;ll just wake up.</p>



<p>I promise that&#8217;s what will happen. Also if you look at the middle of the screen right now you</p>



<p>should see a QR code which you can scan in order to go to the website which I think is also named</p>



<p>somewhere at the bottom of this video and it&#8217;ll take you to my main website where you can just</p>



<p>all the videos i published and the services and tutorials and things that i offer and all that</p>



<p>good stuff and uh if you have a suggestion for uh uh clarifications or errata or just future videos</p>



<p>that you want to see please leave a comment or if you just want to say hey what&#8217;s up what&#8217;s going on</p>



<p>you know just send me a comment whatever i also wake up for those in the middle of the night i</p>



<p>get i wake up in a cold sweat and i&#8217;m like it would really it really mean the world to me i</p>



<p>really appreciate it. So again, thank you so much for watching this video and enjoy the cool music</p>



<p>as I fade into the darkness, which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/ddd-debugger-tutorial-fast-guide-to-debugging-c-c-code/">DDD Debugger Tutorial: Fast Guide to Debugging C++ &amp; C Code</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/ddd-debugger-tutorial-fast-guide-to-debugging-c-c-code/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Master GNU Debugger: Debug C++ &#038; Assembly Programs with GDB Like a Pro</title>
		<link>https://www.NeuralLantern.com/master-gnu-debugger-debug-c-assembly-programs-with-gdb-like-a-pro/</link>
					<comments>https://www.NeuralLantern.com/master-gnu-debugger-debug-c-assembly-programs-with-gdb-like-a-pro/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sat, 14 Jun 2025 23:53:13 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[assembly debugging]]></category>
		<category><![CDATA[assembly programming]]></category>
		<category><![CDATA[breakpoints]]></category>
		<category><![CDATA[c++ debugging]]></category>
		<category><![CDATA[C++ programming]]></category>
		<category><![CDATA[call stack]]></category>
		<category><![CDATA[coding for beginners]]></category>
		<category><![CDATA[coding tutorial]]></category>
		<category><![CDATA[debug symbols]]></category>
		<category><![CDATA[debugging tools]]></category>
		<category><![CDATA[GDB]]></category>
		<category><![CDATA[GNU Debugger]]></category>
		<category><![CDATA[null pointer]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software development]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=155</guid>

					<description><![CDATA[<p>Master GDB to debug C++ &#038; assembly! Learn breakpoints, call stacks, &#038; crash fixes in this fun guide for coders.</p>
<p>The post <a href="https://www.NeuralLantern.com/master-gnu-debugger-debug-c-assembly-programs-with-gdb-like-a-pro/">Master GNU Debugger: Debug C++ &amp; Assembly Programs with GDB Like a Pro</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Master GNU Debugger: Debug C++ &amp; Assembly Programs with GDB Like a Pro" width="1380" height="776" src="https://www.youtube.com/embed/lPcwsvSWak0?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Hey everybody! Ready to crush those pesky bugs in your C++ and assembly programs? In this video, we’re diving deep into the GNU Debugger (GDB) – the ultimate tool for tracking down crashes, inspecting variables, and mastering your code. From setting up debug symbols to navigating call stacks, setting breakpoints, and even debugging assembly registers, this fun and relatable guide has you covered. Whether you’re a beginner coder or a seasoned dev, you’ll learn practical tips to level up your debugging game. We’ll also tackle null pointers, create GDB scripts, and explore why your program might be misbehaving. Stick around for a few laughs and some serious skills! Don’t forget to subscribe, hit that like button, and check out my website for more coding tutorials. Let’s debug like pros together!</p>



<p>Introduction to GNU Debugger 00:00:00<br>What is a Debugger 00:00:20<br>Debug Symbols Explanation 00:02:08<br>Compiling with Debug Symbols 00:03:13<br>File Size Comparison 00:05:30<br>Installing and Launching GDB 00:06:21<br>GDB Console Basics 00:06:55<br>Attaching GDB to Program 00:08:12<br>Running Program in GDB 00:09:09<br>Handling Program Crash 00:13:02<br>Understanding Call Stack 00:14:05<br>Navigating Call Stack 00:18:13<br>Inspecting Variables 00:19:08<br>Null Pointer Issues 00:21:25<br>Using GDB Script 00:25:10<br>Setting Breakpoints 00:27:04<br>Managing Breakpoints 00:28:37<br>Continuing Execution 00:30:41<br>Debugging Assembly 00:33:24<br>Global Variables in Assembly 00:35:43<br>Advanced GDB Commands 00:38:31<br>Conclusion and Call to Action 00:40:22</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hey everybody! In this video I&#8217;m going to show you how to use the GNU Debugger to</p>



<p>debug your C++ and assembly programs.</p>



<p>You can also use it for C and some other stuff but we&#8217;re just going to focus on</p>



<p>C++ and assembly. What is the GNU Debugger and what is a debugger in the</p>



<p>first place? So for starters the GNU Debugger it&#8217;s like it&#8217;s called GDB and</p>



<p>the db you can imagine that stands for debugger something like that and the g stands for gnu i</p>



<p>personally don&#8217;t know how to uh pronounce gnu so i just say gnu because it it feels more fun to do</p>



<p>it that way it&#8217;s more interesting i think probably some people just say new but i don&#8217;t like that</p>



<p>because the gdb debugger is really old and robust and powerful it&#8217;s not a new tool it&#8217;s it&#8217;s an old</p>



<p>new debugger someone&#8217;s always going to ask what was the old debugger and then I say this is the</p>



<p>old debugger the new debugger is the old debugger anyway so we&#8217;re going to use the GNU debugger</p>



<p>if you haven&#8217;t yet watched my video on caveman debugging you probably want to watch that first</p>



<p>just for like some basics of you know why you might want to look at information in your program</p>



<p>but for now we&#8217;ll just assume that you already know what&#8217;s going on with just like why you would</p>



<p>know how to make make files see my other videos but here i just have a basic make file all it&#8217;s</p>



<p>really going to do is just sort of compile a very simple program and add debug symbols into it so</p>



<p>let&#8217;s double check that i&#8217;m actually doing that here yeah there we go okay so the first thing</p>



<p>that i should probably show you is uh we are compiling a c plus plus source module so i&#8217;ve</p>



<p>actually using c but i i have that left over in there anyway and then we&#8217;re assembling something</p>



<p>in yasm we&#8217;re linking with g plus plus because we want to have a hybrid program and we&#8217;ve got</p>



<p>all these flags here those are just variables and so uh so now before i can debug with gdb</p>



<p>i&#8217;ve got to talk about something called debug symbols what are debug symbols imagine just a</p>



<p>bunch of extra information explaining all of the design and variables and everything inside of your</p>



<p>about your code stuffed directly into the executable.</p>



<p>So imagine, you know, when we compile a C++ source module</p>



<p>into an object file, usually that&#8217;s just, you know,</p>



<p>assembly at that point.</p>



<p>But when we add debug symbols, we&#8217;ll have a bunch of information</p>



<p>that can help the debugger figure out where we are in the program,</p>



<p>what the variables look like, you know,</p>



<p>a bunch of extra information to help the debugger pretty much.</p>



<p>The assembler will put debug symbols into the object code</p>



<p>symbols into the object code that you generate the compilers will do that the linker will do that</p>



<p>and so it&#8217;s important to understand if you don&#8217;t generate debug symbols when you&#8217;re compiling and</p>



<p>linking your code then your debugger won&#8217;t actually be able to do anything it won&#8217;t understand what&#8217;s</p>



<p>going on you can debug it but like you&#8217;re not going to see anything that&#8217;s very uh that&#8217;s useful</p>



<p>so let me show you real fast i&#8217;m going to do make clean and then i&#8217;m going to say make build</p>



<p>that I do not have debug symbols.</p>



<p>All right, okay, if you don&#8217;t know how to compile and link from the command line, see</p>



<p>my other videos, but for now it looks like we&#8217;re not generating debug symbols.</p>



<p>So if I list the contents of my directory here, just note the size is real fast.</p>



<p>I have an assembly module here that I&#8217;m calling ASI.asm, ASI for assembly, and then we&#8217;re</p>



<p>assembling it down to an object file.</p>



<p>Notice how it&#8217;s just 656 bytes, very small.</p>



<p>plus plus module that I&#8217;m creating here is compiling to an object file that is</p>



<p>about four and a half kilobytes so you know not too big the final executable is</p>



<p>called main and it&#8217;s about 17 kilobytes so this is without debug symbols when</p>



<p>you&#8217;re compiling something on your own you need to add extra switches to enable</p>



<p>debug symbols so you can see here in this make file that I&#8217;ve made and again if</p>



<p>you don&#8217;t know how to make a make file or compile or link or anything see my</p>



<p>But for now, I&#8217;m just going to assume you kind of know your way around to makefile,</p>



<p>or at least you can kind of infer what&#8217;s going on.</p>



<p>So I&#8217;ve commented out a different version of this variable for the flags of my C++ compiler.</p>



<p>If I uncomment this and then comment out the other one,</p>



<p>you&#8217;ll notice the only real difference is this part right here, dash G dwarf 2.</p>



<p>Usually in C++ compilation, it&#8217;ll just be dash G to generate debug symbols,</p>



<p>and then the symbol format will default to a format called dwarf2 so I don&#8217;t know for these</p>



<p>tutorials I like to just specify the full format but you can just say dash g in your c++ compiler</p>



<p>and linker we do the same thing for the linker down here so I&#8217;m going to uncomment this</p>



<p>and comment that and the only difference is just g dwarf2 so I&#8217;m just telling my linker that I also</p>



<p>want debug symbols in there too then we do the same thing for the assembler so I&#8217;m going to</p>



<p>So I&#8217;m going to uncomment that and comment this other one.</p>



<p>And the only difference is that in the assembler,</p>



<p>we kind of have to specify it a little bit differently.</p>



<p>Instead of G dwarf dash two,</p>



<p>it&#8217;s just G dwarf two as just one string.</p>



<p>And I think with Yasm, you have to specify the debug symbol format.</p>



<p>So just keep that in mind.</p>



<p>So now I&#8217;ve turned on all the debug symbols.</p>



<p>I&#8217;m going to do real fast, make clean and make build one more time.</p>



<p>And then if I list everything,</p>



<p>list everything let me just double check that it&#8217;s building the symbols now right okay good</p>



<p>notice that the files are bigger so this asio um file is now 1.8 kilobytes instead of you know</p>



<p>half a kilobyte the main.o object file is now 36 kilobytes instead of only 4.5 and the executable</p>



<p>main is 36 kilobytes instead of just 17. so you can feel it already right like there&#8217;s a bunch</p>



<p>extra information sitting inside the object files and the binary which allows us to debug our program</p>



<p>okay so now that we&#8217;ve generated debug symbols in our program we can actually think about starting</p>



<p>to use gdb so gdb is a program just gdb by the command line if you don&#8217;t have it in your system</p>



<p>already you can go sudo apt install gdb or depending on what system you&#8217;re on maybe a or</p>



<p>or whatever your package management program is,</p>



<p>but we just need to install GDB.</p>



<p>On Ubuntu and Debian, I think,</p>



<p>there is a meta package called build essential,</p>



<p>which will give you a bunch of compilation tools</p>



<p>and make file stuff and whatever.</p>



<p>So I&#8217;m just going to assume at this point</p>



<p>you already have GDB on your system.</p>



<p>To launch GDB and go into its console,</p>



<p>just type GDB by itself.</p>



<p>So now we&#8217;re inside of the GDB console or terminal.</p>



<p>console or terminal. We&#8217;re no longer inside of a bash terminal. We can&#8217;t type normal commands.</p>



<p>Let me show you real fast. Here&#8217;s the first command you want to learn on GDB. It&#8217;s called</p>



<p>quit. Never quit. Never surrender. So, you know, normally if you&#8217;re at the command line,</p>



<p>you can do something like cat, etc. OS release just to see what operating system you&#8217;re using.</p>



<p>So you can see for this virtual machine that I&#8217;m using right now, I&#8217;ve got like Ubuntu 22 on there.</p>



<p>If we go inside of GDB, we can&#8217;t use regular bash commands anymore or regular operating</p>



<p>system commands.</p>



<p>We can&#8217;t say cat, et cetera, OS release because we can now only use GDB commands.</p>



<p>We&#8217;re inside of GDB already.</p>



<p>Notice how it says undefined catch command.</p>



<p>I don&#8217;t know what you&#8217;re talking about, dude.</p>



<p>Okay.</p>



<p>So remember we do a Q or quit to get out.</p>



<p>You can actually just type Q.</p>



<p>A lot of commands that I&#8217;m going to be talking about.</p>



<p>going to be talking about you can abbreviate them with one or two or three letters and it totally</p>



<p>works just for speed so now that we know how to enter gdb and now that we also know that we have</p>



<p>already compiled our program with debug symbols we can attach gdb to our program i mean what&#8217;s the</p>



<p>whole point of a debugger we most of the time we will just have our debugger attached to our program</p>



<p>and launch it or i guess launch it while it&#8217;s attached you can also attach to a running program</p>



<p>but we&#8217;re going to launch a program and stay attached to it.</p>



<p>And then we can sort of catch crashes and see what&#8217;s going on.</p>



<p>Or we could also tell the debugger to stop the program at certain points in time,</p>



<p>like when we hit a certain line number or when a variable changes or something like that.</p>



<p>And then we can look around.</p>



<p>We can look at all the variables, look at the state of the program,</p>



<p>even change things if we wanted to.</p>



<p>We can look at all the registers if you&#8217;re coding in assembly.</p>



<p>So it&#8217;s pretty useful.</p>



<p>Anyway, I&#8217;m going to go gdb and the next command we&#8217;re going to learn is file, which just tells</p>



<p>gdb to attach to a program so that we can run it.</p>



<p>So, you know, the name of our program here that we compiled is just called main.</p>



<p>And so if I type file main, then gdb should load up that file and try to parse its debug</p>



<p>symbols so it can begin debugging for you.</p>



<p>Notice how it says reading symbols from main.</p>



<p>you know if we did a typo or we had something with no debug symbols it will give us some sort</p>



<p>of an error message so for now i&#8217;m just going to quit and then go back in just to make sure that</p>



<p>it&#8217;s all clean and we&#8217;re going to do file main now it attaches once it&#8217;s attached that&#8217;s not i guess</p>



<p>it&#8217;s not technically attached because the program&#8217;s not running but once it has loaded the debug</p>



<p>symbols for that program we can run the program with the run command in gdb also kind of interesting</p>



<p>If you have debug symbols that are generated separately from your executable,</p>



<p>you could tell GDB to load the symbols file and then run your program.</p>



<p>That happens a lot in Linux where people release the non-debug friendly version of a program</p>



<p>and then they&#8217;ll release the debug symbols separately if you&#8217;re interested.</p>



<p>Anyway, so I&#8217;m going to type run and it&#8217;ll run the program.</p>



<p>Notice how GDB kind of tells us that it&#8217;s starting up now.</p>



<p>here&#8217;s like a thread debugger that&#8217;s being enabled and it says we&#8217;re using this library to do it and</p>



<p>then it says hello you know here&#8217;s the hello message so the program is actually running that&#8217;s</p>



<p>not my name i wish it was and then it prints the final result and then gdb says your program exited</p>



<p>normally on newer versions of gdb there&#8217;s a setting i think by default where it&#8217;ll ask you</p>



<p>if you want to start a debug daemon a debug info daemon or something yes or no you can usually just</p>



<p>without actually having to type n.</p>



<p>It&#8217;s a little bit faster.</p>



<p>So the whole program ran and finished.</p>



<p>If I type run again, it does the same thing.</p>



<p>In GDB, if you hit enter without typing anything,</p>



<p>it ends up repeating the previous command.</p>



<p>So I&#8217;m not going to type run.</p>



<p>If I just hit enter, are you serious?</p>



<p>GDB made me into a liar.</p>



<p>Well, most of the commands will repeat if you hit enter.</p>



<p>I guess not the run command.</p>



<p>So I&#8217;ll type run again.</p>



<p>And okay, I mean, the program is pretty good, right?</p>



<p>So if you watched my…</p>



<p>It&#8217;s not pretty good.</p>



<p>watched my it&#8217;s not pretty good it&#8217;s a nonsense program I mean it it doesn&#8217;t crash is what I&#8217;m</p>



<p>saying if you watched my previous video which you should on caveman debugging I had this uh you know</p>



<p>nonsense portion of code that just sort of updated a variable and we pretended that we were confused</p>



<p>and we didn&#8217;t understand what was happening and uh we used gdb to debug it so what I&#8217;m going to do</p>



<p>either let&#8217;s say we&#8217;ll start off with throwing an exception and then we&#8217;ll try to use a no pointer</p>



<p>and then we&#8217;ll see a crash and then after that I&#8217;m going to start using breakpoints where we can stop</p>



<p>automatically inside of our program to print the state of the program print the variables</p>



<p>and then I&#8217;m going to do that first in C++ and then hopefully I&#8217;ll remember to do that in</p>



<p>assembly right after it&#8217;s basically the same thing only with assembly you don&#8217;t really have</p>



<p>you know a bunch of variables everywhere you just kind of have registers and maybe some globals</p>



<p>globals but it&#8217;s going to be the same deal okay so let&#8217;s pretend that uh we are gonna have a crash</p>



<p>okay so this program just kind of runs later on we&#8217;ll figure out why the result is wrong we&#8217;ll</p>



<p>just pretend that it&#8217;s wrong but for now we&#8217;ll just say how about we uncomment this line right</p>



<p>here and what will happen is when we&#8217;re running the main loop at some point in the loop we get</p>



<p>When F gets called, the input will be looked at here.</p>



<p>And if the input is more than one,</p>



<p>which is definitely gonna happen like right away,</p>



<p>then we&#8217;ll call on the G function.</p>



<p>Then the G function will just throw an exception.</p>



<p>We&#8217;ll just pretend that something really bad happened.</p>



<p>You crashed or you actually did throw</p>



<p>and you didn&#8217;t catch your throw,</p>



<p>or maybe the system threw something at you</p>



<p>or another library threw something at you</p>



<p>and you didn&#8217;t catch it.</p>



<p>So just basically a program crash.</p>



<p>Let me run this real fast.</p>



<p>So make run just to show you that the program crashes.</p>



<p>Make run at this point is the same thing as just kind of executing the program.</p>



<p>But you can see that it says terminate called after throwing an instance of runtime error.</p>



<p>And then there&#8217;s the message, oh my gosh, and then aborted core dumped.</p>



<p>That&#8217;s not good.</p>



<p>So now let&#8217;s try to understand why.</p>



<p>Why did that crash?</p>



<p>Pretend you don&#8217;t know that it happened in G. You know, you&#8217;re trying to investigate.</p>



<p>So we could type GDB and then we could type a file to load the debug symbols, but it&#8217;s a little bit faster just to type GDB main and just sort of name the file that you want to load right away.</p>



<p>So if I do that, notice how it automatically tries to load the debug symbols from main.</p>



<p>Then I can just type run and then the program tries to run and notice how it actually catches the crash.</p>



<p>If you look down here, terminate called after throwing an instance of runtime error.</p>



<p>throwing an instance of runtime error so that&#8217;s what the program thinks is going on but then the</p>



<p>program is trying to terminate but then down here gdb is like wait wait wait i just caught you know</p>



<p>a termination uh getting invoked here and you can see this is sort of system code like we did not</p>



<p>create this source file p thread kill we didn&#8217;t write that that&#8217;s the standard library and there&#8217;s</p>



<p>a function here called p thread kill implementation with those you know fun c underscore prefixes</p>



<p>prefixes everywhere and so this is like some sort of a c source file and we don&#8217;t have that file on</p>



<p>the system so we can&#8217;t really debug that file lucky for you most of these standard libraries</p>



<p>work all the time so you don&#8217;t really need to debug them you need to debug your code instead</p>



<p>of the standard library code so the question really is how did i get here how did i get to</p>



<p>this crash so the next command we&#8217;ll learn in gdb is just the where command the where command will</p>



<p>I&#8217;m going to release a video in the future that kind of explains call stacks, but basically</p>



<p>imagine a abstract data type, a data structure called a stack. And every time you want to add</p>



<p>data to the stack, it just sort of stacks up on top of the last piece of data. So like if I add</p>



<p>something, let&#8217;s say I want to add the number five, then I would just add the number five on top of</p>



<p>the stack, right? If I wanted to add the number 11, then I would just add the number 11 onto the</p>



<p>off of the stack and the stack is a really good data structure to uh sort of give you a trail of</p>



<p>breadcrumbs to know where you got where did you come from so we call this the call stack because</p>



<p>what&#8217;s happening is every single time you call a function then the new scope and then you know the</p>



<p>new function that you&#8217;re invoking um it has something called a call frame full of information</p>



<p>current address is and all that stuff.</p>



<p>And we&#8217;ll just call that chunk of data that belongs to one instance of a function call.</p>



<p>We&#8217;ll just call that a call frame.</p>



<p>And so if you&#8217;re stacking call frames one on top of the other,</p>



<p>then we call that whole entire thing the call stack.</p>



<p>And this is what allows us to use recursion and all these complicated call graphs and everything.</p>



<p>It&#8217;s really simple, but it&#8217;s really powerful.</p>



<p>So you&#8217;re looking at the call stack.</p>



<p>Each one of these lines is the call frame or is a call frame.</p>



<p>And so for example, if you just look at number zero here, you&#8217;re looking at call frame zero,</p>



<p>which is the closest frame to wherever the crash occurred, which is if you look at it,</p>



<p>that&#8217;s exactly what we were looking at when we saw that original message, right? Call frame zero.</p>



<p>So that&#8217;s not really useful. You want to go down to higher numbered call frames or I guess</p>



<p>physically lowered number call frames and just kind of scan it until you find some code that</p>



<p>raise no abort no none of this stuff is ours live standard c plus plus no the first frame that</p>



<p>contains code that is ours is call frame number nine or i guess like nine away from our current</p>



<p>position so i guess find the physically highest call frame that is your code or the lowest numbered</p>



<p>call frame that is your code and it&#8217;s telling us right here all right we uh we actually seem to</p>



<p>So if I go to 65, right there, it tells you exactly where the crash happened.</p>



<p>If you&#8217;re still trying to figure out, well, how did I get to that crash?</p>



<p>I don&#8217;t know how that actually happened.</p>



<p>Just keep looking down further in the call frames.</p>



<p>The next one, call frame 10, says, well, we were inside of function f with input equals</p>



<p>three at main.cpb line 46.</p>



<p>So if I just go to 46, I can get another clue.</p>



<p>I can go, all right, so for some reason we called g.</p>



<p>Imagine again, this program is much more complicated.</p>



<p>And then if we&#8217;re still confused, we just look down at another one and it&#8217;s like, well, this all this whole mess started at CPP main dot CPP line 28.</p>



<p>So if we look at line 28, it&#8217;s like, well, we were inside of this loop and we we called the F function and then the F function called the G function.</p>



<p>And then G just kind of did a throw. So that gives us a lot of information.</p>



<p>All right. Next thing we can do is we can sort of move up and down the call stack, because right now we&#8217;re sitting at call frame zero, which is just the system code.</p>



<p>which is just the system code, but maybe we don&#8217;t understand why the throw actually happened at,</p>



<p>let&#8217;s say, line 65, right? So we can use up to go up in the call stack to a different call frame.</p>



<p>So if I hit up, notice how it mentions that we&#8217;re now in frame number one instead of zero.</p>



<p>And if I do up again, we&#8217;re now in frame two, which is a little bit closer. We can use the</p>



<p>trick finally where we hit the enter key instead of repeating the command. So I&#8217;m just going to</p>



<p>and hit enter a couple times until we eventually get to our code,</p>



<p>which I think was supposed to be at frame nine.</p>



<p>So I&#8217;m just going to hit it a bunch of times until we get to frame nine.</p>



<p>Now we&#8217;re looking sort of back in time at that point</p>



<p>because all these other frames actually did get invoked,</p>



<p>but we don&#8217;t really care about what was going on inside of them</p>



<p>because they probably did their job correctly.</p>



<p>We&#8217;re looking at our code, so we&#8217;re going back in time</p>



<p>right when we were doing this throw.</p>



<p>Oh no, we threw. Why did we throw?</p>



<p>well there&#8217;s another command in gdb called info locals</p>



<p>okay the info locals uh there&#8217;s there&#8217;s really not much to this maybe maybe let me do this again</p>



<p>a equals five and uh then i&#8217;ll just say a plus plus just so that we have a local variable</p>



<p>i forgot that gdb doesn&#8217;t consider the incoming arguments as locals so there was nothing there</p>



<p>real fast uh gdp oh let&#8217;s do make build and then gdp main and then run and then we have a throw</p>



<p>and then i say where and then i go up up up up to a frame you can also use the keyword down if you</p>



<p>go too far if you want to go you know back down in the call stack but i&#8217;m just going to use up</p>



<p>okay so now we have it here now finally i think i can do info locals just to see the local variables</p>



<p>notice how the a variable is there now because I just added a local variable a a moment ago</p>



<p>you can also print things directly you can say print the input incoming variable if you&#8217;re in</p>



<p>assembly you can also print registers you can say info registers like that and you&#8217;ll get a nice</p>



<p>print out of all the registers you could print individual registers you can say let&#8217;s print</p>



<p>register r12 you can print register r12 as binary by saying I think it&#8217;s p slash t</p>



<p>or print slash t yeah we can probably just do print slash t also</p>



<p>t stands for two because they&#8217;re it&#8217;s a base two number system</p>



<p>does that mean there&#8217;s a p slash h or a p slash f for 15 or 16 s for 16 i don&#8217;t know i haven&#8217;t</p>



<p>tried that is it going to work hang on p slash s bar 12 it&#8217;s not going to work nope didn&#8217;t work</p>



<p>i think it thinks it&#8217;s a character point or something but anyway so we can print a lot of</p>



<p>So we can print a lot of stuff.</p>



<p>And like I said before, we can go up and down the call stack.</p>



<p>So I can go down a couple times and then go back up again.</p>



<p>And now we can assume that we&#8217;ve kind of debugged, you know, where the source of the error was.</p>



<p>So I&#8217;m going to comment that call out to G and run the program again one more time with a different error.</p>



<p>So I&#8217;ve commented this code out from before, but just imagine now that we&#8217;re going to use some pointers.</p>



<p>We&#8217;re going to start off with a pointer called P.</p>



<p>a pointer called p we&#8217;re going to set it to null at the beginning and then we&#8217;re going to just</p>



<p>kind of allocate it and then we&#8217;re going to set you know a value and then we&#8217;re going to dereference</p>



<p>it and dereferencing a pointer just kind of sets the first value in an array you can do that and</p>



<p>then we&#8217;re going to deallocate the pointer and then how about right after that we do something</p>



<p>really really naughty we say p at some index is equal to a five this should be this should be a</p>



<p>a program crash because we deallocated p already at that point we would be dealing with junk data</p>



<p>if we tried to dereference p but to make it even more clear that it&#8217;s naughty we&#8217;ll set it to a no</p>



<p>pointer and then we&#8217;ll try to actually use it so let me let me just restart the program real fast</p>



<p>i&#8217;m gonna do quit yes and then we&#8217;ll do make a debug just so you know my make debug is just a</p>



<p>Let&#8217;s see, where&#8217;s that? Where&#8217;s that? Where&#8217;s that? Do I not have a debug shortcut yet?</p>



<p>Oh dear. I need to add that before this video is over. You know what? I&#8217;ll add it right now.</p>



<p>We&#8217;ll do this run and we&#8217;ll say debug, make debug, and it needs to build first. And then I&#8217;ll say</p>



<p>debugging the program. And then we will do the GDB binary and give it an argument of</p>



<p>the executable and then later we can we can upgrade this to take a little script of commands</p>



<p>because the commands are going to start getting out of control so now if i do make debug if i</p>



<p>didn&#8217;t screw it up now it at least goes in there and i&#8217;ll do run and then we have a seg fault and</p>



<p>notice how it tells us right away hey you have a seg fault right here you&#8217;re accessing invalid</p>



<p>memory let&#8217;s do info locals just to see what&#8217;s up oh the p is actually a zero that&#8217;s a null pointer</p>



<p>explicitly oh whoops you know oh what have I done but it&#8217;s a really good idea to set your</p>



<p>pointers to null after you deallocate because if you don&#8217;t you might end up with undefined</p>



<p>behavior where sometimes the program doesn&#8217;t crash while you&#8217;re overriding junk data or reading junk</p>



<p>data but sometimes it does and you&#8217;re not really sure like why does it work sometimes and why does</p>



<p>it not work sometimes so let me comment this out and see if it&#8217;ll crash uh let&#8217;s just let&#8217;s just</p>



<p>make debug and then i&#8217;ll do run and then if we do info locals oh yeah okay so this is uh</p>



<p>it did seg fault so that&#8217;s good uh if we were unlucky then the program wouldn&#8217;t have crashed</p>



<p>it would have just started behaving strangely and um when we print out the value of p notice how it</p>



<p>looks like a pointer still like if we were to debug the program and print the pointer value</p>



<p>then it doesn&#8217;t really it looks the same it looks the same after we deallocated it right so that</p>



<p>this is called a dangling pointer meaning you deallocated the pointer but you forgot to set</p>



<p>it to null afterwards so then later when you&#8217;re trying to debug the program it&#8217;s a little confusing</p>



<p>because you&#8217;re like that looks like a regular pointer what did i do wrong so um it&#8217;s really</p>



<p>good practice to set your pointers to null right after you deallocate them that way when you&#8217;re</p>



<p>debugging later because something crashed instead of seeing a memory location on p you&#8217;ll see</p>



<p>On P, you&#8217;ll see something that looks definitely like a null pointer and print P.</p>



<p>Then it&#8217;s way easier to realize, oh, whoops, I was trying to use a dead pointer, a pointer that I deallocated.</p>



<p>Hopefully that makes sense so far.</p>



<p>Next thing I want to do is a small upgrade.</p>



<p>I can&#8217;t remember if it&#8217;s dash X or dash EX.</p>



<p>I think it&#8217;s dash X.</p>



<p>But you can write a little script.</p>



<p>I have a little script here called Good Doggo.</p>



<p>called good doggo you can just make any file name it anything you want i&#8217;m so i&#8217;m just naming it</p>



<p>good doggo.txt because my dog&#8217;s taking a little nap behind me as usual um but you could name this</p>



<p>gdb.txt or whatever it is you want so you can put inside of this script file any command that you</p>



<p>want gdb to execute when it launches so let&#8217;s just comment this stuff out real fast and i&#8217;ll do</p>



<p>I&#8217;ll just do run maybe for starters.</p>



<p>Because whenever I&#8217;ve been launching for debug,</p>



<p>I launch with GDB and then I type run manually, right?</p>



<p>So I want to save a little time.</p>



<p>So good doggo is the name of the script.</p>



<p>So when I invoke GDB, I am going to,</p>



<p>where is it right there?</p>



<p>Okay, it&#8217;s GDB.</p>



<p>And then I&#8217;m going to go dot, I think it&#8217;s X.</p>



<p>And then I&#8217;m going to say good doggo.txt.</p>



<p>If it&#8217;s not dash x, then it&#8217;s dash ex.</p>



<p>One of those executes the command that comes after,</p>



<p>and one of those executes the command script that comes after.</p>



<p>Let me just double check that this actually is going to work.</p>



<p>So make debug.</p>



<p>All right, okay, so it was dash x.</p>



<p>Dash x specifies a script that will be run.</p>



<p>Dash ex just specifies a command that you can put right in there.</p>



<p>Like I could have said dash ex run, and it would have ran right away.</p>



<p>But the script is more convenient, right?</p>



<p>Because we can save typing.</p>



<p>So notice how it ran right away and then there&#8217;s a seg fault.</p>



<p>Okay, so now let&#8217;s go a little bit deeper.</p>



<p>Let&#8217;s change this to false again now that we understand like null pointers and all that</p>



<p>stuff.</p>



<p>So we can just basically deal a little bit more with only what the main loop is doing.</p>



<p>Suppose we just still don&#8217;t really understand what the loop is doing, why our answer is</p>



<p>you know, good or bad.</p>



<p>So maybe I want to do a breakpoint at the top of that for loop.</p>



<p>loop gets to the top of its iteration, I want the program to pause so I can look around.</p>



<p>So I&#8217;m going to set up a breakpoint on line 22. And here&#8217;s how you set up breakpoints</p>



<p>in GDB. I&#8217;m going to go ahead and maybe do the terminal for now. And then I&#8217;ll stick that into</p>



<p>the script next. I will not remember that it&#8217;s line 22. That&#8217;s okay. I&#8217;m going to do quit.</p>



<p>And I&#8217;m going to do make build. Then I&#8217;m going to go GDB main just to jump in there.</p>



<p>and then i&#8217;m going to say break or just the letter b just to make a break point you type the name of</p>



<p>the source code file that you want to break in and then a colon and then the line number where</p>



<p>you want it to break so i think i think it actually was line 22 oh i can see it and then</p>



<p>maybe i want to have it break at line i don&#8217;t know maybe right here line 25 right before it increases</p>



<p>And then so I&#8217;m going to do an up arrow to just repeat the command so I can edit it real fast.</p>



<p>And then I&#8217;ll break again at line 28 and then maybe 30 and then 32.</p>



<p>So I&#8217;m going to go 28, 30 and 32.</p>



<p>30 and I&#8217;m just making up break points.</p>



<p>I just want to inspect the program and then maybe I&#8217;ll break at line 36 so I can see what the final answer is.</p>



<p>So I just have a bunch of break points set up.</p>



<p>Remember when the program is running now under GDB, every time it hits one of those lines,</p>



<p>every time it hits one of those lines the program will pause and i&#8217;ll have a chance to look around</p>



<p>at the variables and things so i&#8217;m not sure if i&#8217;ve set up the breakpoints correctly i can say</p>



<p>info breakpoints and it&#8217;ll show me all of my breakpoints notice how you can enable them and</p>



<p>disable them so let&#8217;s say for the sake of argument i want to disable the breakpoint at line 30 because</p>



<p>maybe i don&#8217;t really need that right now but i kind of want to keep it in the system for later</p>



<p>disable four because it&#8217;s number four.</p>



<p>It&#8217;s breakpoint number four.</p>



<p>So I can say disable four.</p>



<p>Then if I do info breakpoints again,</p>



<p>notice how there&#8217;s a little N on there,</p>



<p>meaning breakpoint four is disabled.</p>



<p>So I could re-enable it with a four</p>



<p>and then go info breakpoints again.</p>



<p>So now they&#8217;re all enabled.</p>



<p>I am going to maybe copy this into the script file real fast</p>



<p>so I don&#8217;t have to keep typing this over and over and over again.</p>



<p>Imagine if every single time you changed your program and recompiled it you had to type all of the breakpoints from scratch</p>



<p>That&#8217;s why I want you to use this little breakpoint script</p>



<p>So we&#8217;re going to do B to break at main.cpp line 22 and 25 and</p>



<p>28 and</p>



<p>30 and 32. I should have copy pasted the three dang it 36</p>



<p>And after we&#8217;re done setting up all the breakpoints</p>



<p>show me the breakpoints just so I can have a visual reminder. Keep in mind if you change too</p>



<p>much of your source code then you&#8217;re probably going to have to update these lines and that&#8217;s</p>



<p>okay but it&#8217;s a good idea to just at least you know kind of look at them a little bit so that&#8217;s</p>



<p>why I&#8217;m saying info breakpoints. And so then remember again the makefile all it&#8217;s doing when</p>



<p>I type make debug is it&#8217;s just launching this command right here it&#8217;s just saying gdb with the</p>



<p>with my gdb script so let me quit to get out of this and then i&#8217;m going to say clear and make</p>



<p>debug and notice how it did all that stuff for me it added the breakpoints it showed me the break</p>



<p>points and then it ran the program like i told it to and then it already broke on a breakpoint it</p>



<p>already break it break breakened it&#8217;s broken i don&#8217;t know i don&#8217;t think it&#8217;s broken uh so we&#8217;re</p>



<p>So we&#8217;re on breakpoint number one on line 22.</p>



<p>And here&#8217;s the for loop.</p>



<p>I can type all of my inspection stuff.</p>



<p>I can say info locals.</p>



<p>I can say print I, I can say print A, I can print whatever I want.</p>



<p>And then when I&#8217;m done kind of looking around and inspecting things,</p>



<p>I want to continue the program.</p>



<p>I don&#8217;t want to just stop it here.</p>



<p>So I&#8217;m just going to use the command continue.</p>



<p>And it goes right to the next breakpoint.</p>



<p>If I want to, you know, continue again, I can hit C.</p>



<p>continue again i can hit c or i can just hit enter you know to just sort of keep continuing as i</p>



<p>inspect and print things let&#8217;s see when can i get to break point number one is that what&#8217;s going on</p>



<p>here hang on a second what is break point number one oh i know what to do info break points</p>



<p>break point number one is that main.cpp line 22 is that actually going to get hit oh it&#8217;s</p>



<p>having issues here with my GUI. Okay. Line 22. Okay. So it&#8217;s not really hitting that anymore.</p>



<p>I guess it&#8217;s not going to think that it hits the top of the forelip. Okay. So I guess breakpoint</p>



<p>two is where we&#8217;re always going to be hitting. So let&#8217;s just suppose that I&#8217;m continuing until</p>



<p>I hit breakpoint number two. Suppose that the next 10 times I see breakpoint two, I don&#8217;t</p>



<p>actually want to stop and break on it. I just want to skip the next 10 iterations for some reason.</p>



<p>some reason you can say continue 10 and it&#8217;ll skip the next 10 times that it hits the number two</p>



<p>notice how if i hit continue a bunch of times we&#8217;re not really seeing the break point number</p>



<p>two anymore we&#8217;re seeing other break points and then eventually if i hit it enough times</p>



<p>we&#8217;ll probably see two again oh my god oh my god are we seeing it yet no</p>



<p>Okay, wait, are we seeing I&#8217;m freaking myself out.</p>



<p>Okay, so let&#8217;s continue 10 times on breakpoint three, then we&#8217;ll only see</p>



<p>breakpoint four, I guess.</p>



<p>So we can do continue 10 times on breakpoint four.</p>



<p>What is going on here?</p>



<p>Did I write this program in a weird way?</p>



<p>Hmm.</p>



<p>Well, trust me on this.</p>



<p>Let&#8217;s continue 100 on breakpoint three and then continue 100 on breakpoint four.</p>



<p>breakpoint 4. Okay, so now we&#8217;re just done with the whole entire program. I guess there must have</p>



<p>been a 2 there that I missed. So now we&#8217;re finally on breakpoint 6, which is when everything is</p>



<p>finished. Let me show you real fast that we can add more breakpoints in assembly just to prove</p>



<p>that we can debug assembly real fast. So if I want to debug assembly, I just have to type the name of</p>



<p>that source code file. If it was nested in a folder, like if you had like a complicated hierarchy of</p>



<p>of source code files you would just need to type the relative path but for now I&#8217;m just going to</p>



<p>be able to type the name of the file so assy.asm and let&#8217;s suppose that I want to break at line</p>



<p>16 just so I can see the registers that I set up so I&#8217;m going to do 16 and then I&#8217;m going to break</p>



<p>at assy.asm line 16 and then I&#8217;m going to run and that actually never gets called does it no no it</p>



<p>called does it no no it gets called I think I have a call up here somewhere</p>



<p>nope I don&#8217;t have a call okay let&#8217;s make a call this is gonna throw off all of my</p>



<p>C++ breakpoints so I&#8217;ll just comment them all out right now comment them all</p>



<p>out so I don&#8217;t have to redo them and this is a hybrid program so I&#8217;m gonna go</p>



<p>extern what is it extern C make a block where I name the function the reason we</p>



<p>name mangling so the AC symbol is going to show up as just its regular function</p>



<p>name rather than a bunch of extra stuff indicating the prototype so that we can</p>



<p>do overloading so we&#8217;re just going to disable that and then at the very top of</p>



<p>the program I&#8217;m just going to call it this should hopefully work let me just</p>



<p>do a regular make run just to make sure the whole program compiles okay now</p>



<p>debug script we&#8217;re gonna break on line 16 which is going to be letting us see</p>



<p>the registers okay so I&#8217;m gonna go make debug notice how it hit the breakpoint</p>



<p>in the assembly just the same as the C++ and we can print whatever we want now so</p>



<p>I&#8217;m just gonna say info registers and if we look carefully we can kind of see</p>



<p>that we modified racks REX is 15 so that&#8217;s expected RDI is 20 which is</p>



<p>R12 should be a giant number. Where&#8217;s R12? Right there. So you can see the state of your program at any point in time just by breaking on it.</p>



<p>I&#8217;m breaking on a certain line. So this is tremendously useful for debugging not just for higher level languages but also assembly.</p>



<p>What else can I do? Oh let&#8217;s put a global in the data section. So I&#8217;m gonna do, I don&#8217;t know, my thing or something like that and we&#8217;ll call it a byte array and I&#8217;ll just go hello.</p>



<p>I&#8217;ll say we have a thing one and a thing two.</p>



<p>Something like that.</p>



<p>And maybe thing two is a null terminated string,</p>



<p>whereas thing one is a regular thing.</p>



<p>We should be able to print those symbols.</p>



<p>If that&#8217;s not true, I&#8217;ll come back at a later time</p>



<p>and show you how to do it.</p>



<p>Anyway, so we&#8217;ll do make debug</p>



<p>to just kind of assemble everything again.</p>



<p>And we know how to do info registers.</p>



<p>We can print, you know, one register in particular,</p>



<p>print R12 if we wanted to.</p>



<p>History has not reached.</p>



<p>History has not reached 12.</p>



<p>Oh, I got to put R12.</p>



<p>Yeah, then we can get the, wait a minute, wait a minute.</p>



<p>Oh, I threw off the line numbers because I added the variables up here.</p>



<p>So now we&#8217;re going to break at 21.</p>



<p>Let me just fix that.</p>



<p>21.</p>



<p>We&#8217;ll do a quit.</p>



<p>Make debug again.</p>



<p>And now we&#8217;re at 21.</p>



<p>If I say info registers, we can see R12 is that big value.</p>



<p>you, but we can also print R12 directly. And we should be able to print my thing one, hopefully,</p>



<p>has an unknown type, oh, we have to cast it. So we can do like basic casting in GDB. So I&#8217;m going</p>



<p>to say this is a character pointer. Remember, all of the assembly symbols are basically pointers,</p>



<p>unless it&#8217;s an EQU, EQU variable. In that case, it&#8217;s more of a define. So I&#8217;m going to print</p>



<p>and then it says error cannot access the memory add address</p>



<p>what the heck did i do wrong how about that cannot access that all right i&#8217;ll come back in</p>



<p>another video because this wasn&#8217;t something that i prepared for just to print strings in globals</p>



<p>i&#8217;ll come back at some later date in the future like five years from now and i&#8217;ll just show you</p>



<p>how to print globals but i hope if you&#8217;re in assembly you probably don&#8217;t need to worry about</p>



<p>You just have globals, but the real problem for you is going to be what&#8217;s inside of your registers and so forth.</p>



<p>You can also deref, I think.</p>



<p>Let me see.</p>



<p>Okay, I&#8217;m going to move on from that.</p>



<p>So anyway, we got a script and we got a lot of basic GDB commands.</p>



<p>Is there anything else that I wanted to show you?</p>



<p>Let me just look at my notes real fast here to make sure I&#8217;m not forgetting to say anything.</p>



<p>make sure I&#8217;m not forgetting to say anything.</p>



<p>So we&#8217;re going to do debug symbols, console, quit, attach to binary,</p>



<p>launching the program, uncaught exception, breakpoints, info, delete,</p>



<p>enable, disable, run, continue, end times, info registers, printing.</p>



<p>Oh, we can print a register in binary.</p>



<p>Forgot to show that.</p>



<p>So we are at a breakpoint, I think.</p>



<p>And if we printed R12 with the regular print, we can also do P slash T to just</p>



<p>p slash t to just sort of print it in binary if you want to i think i might have said that already</p>



<p>either that or i said that like a couple days ago to some and then we can do info locals and</p>



<p>then print a variable and then we get the script file and then we can quit okay so i think this is</p>



<p>pretty much everything that i wanted to show you you now have a basic idea of what we can do inside</p>



<p>of gdb but keep in mind there is so much more you can do in gdb than i can fit in one video</p>



<p>can type help and you can see a list of other major you know areas that gdb can handle um you</p>



<p>can do uh let&#8217;s see i think it&#8217;s help and then like we&#8217;ve got information on aliases breakpoints</p>



<p>data you know whatever we can do i think help breakpoints to see more information on breakpoint</p>



<p>commands yeah so all of the things you can do with breakpoints is like all of these commands here</p>



<p>one page we have to enter to see one more page or see to see all of the results without using</p>



<p>paging anymore so i&#8217;m just hit c and so there&#8217;s like you know we can save trace points we can</p>



<p>try to catch exceptions we can enable disable break points there&#8217;s like unwinders which i&#8217;ve</p>



<p>never even used we can bookmark things we can you know start tracing memory we can rethrow</p>



<p>variables so just keep in mind gdp is incredibly powerful this video barely scratches the surface</p>



<p>but for a programmer who is new to debugging i think this will be very useful to you i hope it is</p>



<p>anyway thanks for watching this video i hope you learned a little bit of stuff and had a</p>



<p>little bit of fun um i will see you in the next video rest yourself and take a nap and have fun</p>



<p>and hug your your loved ones okay I&#8217;m out see you later hey everybody thanks</p>



<p>for watching this video again from the bottom of my heart I really appreciate</p>



<p>it I do hope you did learn something and have some fun if you could do me a</p>



<p>please a small little favor could you please subscribe and follow this channel</p>



<p>channel or these videos or whatever it is you do on the current social media</p>



<p>website that you&#8217;re looking at right now it would really mean the world to me</p>



<p>and it&#8217;ll help make more videos and grow this community so we&#8217;ll be able to do</p>



<p>more videos longer videos better videos or just I&#8217;ll be able to keep making</p>



<p>videos in general so please do do me a kindness and and subscribe you know</p>



<p>sometimes I&#8217;m sleeping in the middle of the night and I just wake up because I</p>



<p>know somebody subscribed or followed it just wakes me up and I get filled with</p>



<p>That&#8217;s exactly what happens every single time.</p>



<p>So you could do it as a nice favor to me,</p>



<p>or you could troll me if you want to just wake me up in the middle of the night.</p>



<p>Just subscribe, and then I&#8217;ll just wake up.</p>



<p>I promise that&#8217;s what will happen.</p>



<p>Also, if you look at the middle of the screen right now,</p>



<p>you should see a QR code, which you can scan in order to go to the website,</p>



<p>which I think is also named somewhere at the bottom of this video.</p>



<p>And it&#8217;ll take you to my main website,</p>



<p>where you can just kind of like see all the videos I published,</p>



<p>and the services and tutorials and things that I offer,</p>



<p>and all that good stuff.</p>



<p>things that I offer and all that good stuff. And, uh, if you have a suggestion for, uh, uh,</p>



<p>clarifications or errata, or just future videos that you want to see, please leave a comment.</p>



<p>Or if you just want to say, Hey, what&#8217;s up, what&#8217;s going on? You know, just send me a comment,</p>



<p>whatever. I also wake up for those in the middle of the night. I get, I wake up in a cold sweat</p>



<p>and I&#8217;m like, it would really, it really mean the world to me. I would really appreciate it. So</p>



<p>watching this video and enjoy the cool music as I fade into the darkness which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/master-gnu-debugger-debug-c-assembly-programs-with-gdb-like-a-pro/">Master GNU Debugger: Debug C++ &amp; Assembly Programs with GDB Like a Pro</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/master-gnu-debugger-debug-c-assembly-programs-with-gdb-like-a-pro/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Master Two&#8217;s Complement: Convert &#038; Subtract Negative Binary Numbers</title>
		<link>https://www.NeuralLantern.com/master-twos-complement-convert-subtract-negative-binary-numbers/</link>
					<comments>https://www.NeuralLantern.com/master-twos-complement-convert-subtract-negative-binary-numbers/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 18 May 2025 22:53:54 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Conversions]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[binary conversion]]></category>
		<category><![CDATA[binary math]]></category>
		<category><![CDATA[binary numbers]]></category>
		<category><![CDATA[binary subtraction]]></category>
		<category><![CDATA[coding for beginners]]></category>
		<category><![CDATA[computer science basics]]></category>
		<category><![CDATA[negative numbers binary]]></category>
		<category><![CDATA[programming tutorials]]></category>
		<category><![CDATA[signed integers]]></category>
		<category><![CDATA[two's complement]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=110</guid>

					<description><![CDATA[<p>Learn two's complement to represent negative binary numbers with easy examples. Master sign bits &#038; subtraction. Subscribe!</p>
<p>The post <a href="https://www.NeuralLantern.com/master-twos-complement-convert-subtract-negative-binary-numbers/">Master Two&#8217;s Complement: Convert &amp; Subtract Negative Binary Numbers</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Master Two&#039;s Complement: Convert &amp; Subtract Negative Binary Numbers" width="1380" height="776" src="https://www.youtube.com/embed/i2tfzMqlewQ?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Want to conquer negative numbers in binary? This fun, beginner-friendly tutorial breaks down two&#8217;s complement with step-by-step examples (-109, -29) and shows how to convert, pad, and subtract in binary. Learn sign bits, carry bits, and avoid common mistakes. Subscribe for more coding tips and tech tutorials that make learning a blast! Scan the QR code for more resources and join our community!</p>



<p>Introduction to Two&#8217;s Complement 00:00:00<br>Signed vs. Unsigned Integers 00:00:28<br>Sign Bit Explanation 00:01:55<br>Positive and Negative Representation 00:02:06<br>Range of Signed Integers 00:02:48<br>Padding Signed Integers 00:05:36<br>Converting to Negative (Example: -109) 00:07:00<br>Binary Addition and Carry Bits 00:10:16<br>Correcting Conversion Mistakes 00:16:38<br>Converting Negative 29 00:13:32<br>Subtraction Using Two&#8217;s Complement 00:18:21<br>Adding Binary Numbers (109 &#8211; 29) 00:20:41<br>Verifying Results 00:23:56<br>Conclusion and Call to Action 00:25:40</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hey there! Let&#8217;s talk about representing negative numbers in binary.</p>



<p>We&#8217;re going to use a system called 2&#8217;s complement which is going to allow us to represent signed integers,</p>



<p>which means there will be a positive sign or a negative sign on the integer</p>



<p>and we&#8217;ll still be able to do it in pure binary.</p>



<p>So let me talk a little bit about what I mean first here.</p>



<p>signed and unsigned okay so if i just type the number 14 by itself that is uh that&#8217;s an unsigned</p>



<p>integer we don&#8217;t really know if it&#8217;s positive or negative like do we know that it&#8217;s negative 14 or</p>



<p>do we know that it&#8217;s positive 14 right so the sign is what lets us know if something is positive or</p>



<p>negative okay so if i if i type a number in binary let&#8217;s just do a pure binary number one two three</p>



<p>if you know how to convert binary to decimal you probably recognize right away that this is just</p>



<p>the number zero even if we add a couple of bits here that&#8217;s just like the number three</p>



<p>and so this is the number three but so far if if you haven&#8217;t learned signed integers in twos</p>



<p>complement or in binary then you don&#8217;t really know that there&#8217;s a sign you just kind of assume</p>



<p>that the number is positive by default if you&#8217;re not using twos complement and you&#8217;re just saying</p>



<p>and you&#8217;re just saying like well let&#8217;s just do a bunch of binary you know digits then yeah it&#8217;s a</p>



<p>safe assumption that the the sign is positive but we&#8217;ll use two&#8217;s complement which starts with the</p>



<p>idea that the highest bit the leftmost bit the bit with the height you know the most power that&#8217;s</p>



<p>going to turn into the sign that&#8217;s that&#8217;s going to turn into the plus or the minus so like you</p>



<p>the sign.</p>



<p>So this means that we have to decide, you know, does a zero mean positive or does it</p>



<p>mean negative or what means what?</p>



<p>So in two&#8217;s complement, we&#8217;ll say that zero is positive and one is negative.</p>



<p>So you can see right here that we&#8217;re still actually representing the number three, but</p>



<p>it&#8217;s positive three for sure because this sign bit right here is zero.</p>



<p>That&#8217;s positive.</p>



<p>Once we decide to represent two&#8217;s complement, then we can say that for sure.</p>



<p>On the other hand, if we put a one here,</p>



<p>then we definitely know that this number is now negative.</p>



<p>However, we don&#8217;t actually know that it&#8217;s a three</p>



<p>because the numbers don&#8217;t work out the same anymore</p>



<p>in two&#8217;s complement.</p>



<p>So the positive numbers, they will mostly look the same.</p>



<p>The negative numbers, they&#8217;ll look a lot different,</p>



<p>but they&#8217;ll still be valid in order,</p>



<p>you know, in terms of us being able to add them together,</p>



<p>subtract them from each other and things like that.</p>



<p>So two&#8217;s complement is pretty cool.</p>



<p>Let&#8217;s do, let&#8217;s see, what else can I tell you?</p>



<p>Oh, one thing to understand is that</p>



<p>One thing to understand is that in an 8-bit unsigned integer in binary, let&#8217;s say 1, 2,</p>



<p>3, 4, 5, 6, 7, 8, let&#8217;s say unsigned bits, maybe I&#8217;ll just put like, maybe just some</p>



<p>like V for value, all the bits are values, that means the range is 0 to 255 with 256</p>



<p>total combinations.</p>



<p>But if we want to use a signed number, then we&#8217;ll actually have the signed bit be the first bit,</p>



<p>and all the rest will be value bits.</p>



<p>1, 2, 3, 4, 5, 6, 7.</p>



<p>In this case, the range kind of goes down.</p>



<p>Because if you think about it, every single bit, you know, represents like, you know,</p>



<p>it helps towards the highest possible value that you can represent.</p>



<p>If we&#8217;re using the leftmost bit, then for an 8-bit integer, that&#8217;s 128.</p>



<p>integer that&#8217;s 128 that&#8217;s a value of 128 so we lose a lot off of the maximum</p>



<p>integer that we can represent so the range here is I think it&#8217;s negative 20</p>



<p>128 to positive 127 just keep in mind you&#8217;ll have to trust me in terms of why</p>



<p>is the negative 128 bigger and the positive 127 you know smaller but that&#8217;s</p>



<p>just the way it is so that means we only get these value bits here and if you if</p>



<p>that um let&#8217;s see if i can do this quickly enough without screwing it up we&#8217;ll say 127 minus um</p>



<p>minus negative 128 i guess that&#8217;s 255 and then also a zero but uh in terms of positive and</p>



<p>negative the way this is going to work out is the zero will probably show up twice because uh</p>



<p>255 possible combinations with seven bits.</p>



<p>Normally you would have a range from negative, sorry, from zero to positive 255.</p>



<p>And in this case, we&#8217;re just, you know, losing our range, but we can represent negative numbers.</p>



<p>Anyway. Okay.</p>



<p>So let&#8217;s talk about doing an example real fast. Let&#8217;s see.</p>



<p>I&#8217;ve got like a little notes to tell me what I should do. Okay.</p>



<p>It&#8217;s important to understand that normally when you have, let&#8217;s say, let&#8217;s say you have</p>



<p>like an 8-bit number and you go 1, 2, 3, 4, 5, 6, 7, 8.</p>



<p>And then you have 2 bits right there and so this is like, you know, positive 3.</p>



<p>If you wanted to copy that number into more bytes, like for example, if you wanted to</p>



<p>take a 2-byte integer and have it copy the value of a 1-byte integer, then it&#8217;s pretty</p>



<p>easy.</p>



<p>zeros to the left you&#8217;ll say one two three four five six seven eight that would work perfectly</p>



<p>however if you did this with a negative number let&#8217;s say that we have a negative number</p>



<p>I&#8217;m going to put some of the random patterns so that you don&#8217;t think it&#8217;s the three let&#8217;s see</p>



<p>one two three four five six seven eight that&#8217;s eight total so I&#8217;m going to make that a one and</p>



<p>then get rid of that so we have like eight negative number if we were going to copy that</p>



<p>integer then we would copy paste it to start but then you&#8217;d have to pad with</p>



<p>ones to the left one two three four five six seven eight same negative number</p>



<p>more bits so be very careful about how you pad if you&#8217;re padding an unsigned</p>



<p>integer then yeah you&#8217;ll always pad zeros to the left no matter what is</p>



<p>happening but if you&#8217;re padding a signed integer then you have to pad differently</p>



<p>signed integer you have to pad with whatever the highest bit is so in this case the highest bit was</p>



<p>a zero so we do pad with zeros but then in this case the highest bit was a one so we have to pad</p>



<p>with ones if you don&#8217;t do that you&#8217;re going to end up with a number that doesn&#8217;t actually make</p>



<p>sense okay so now let&#8217;s work on actually converting a number to a negative number or representing a</p>



<p>negative number in twos compliment okay so i&#8217;m going to write twos compliment here and then uh</p>



<p>Let&#8217;s start off with the number negative 109.</p>



<p>Okay, how do we do this?</p>



<p>The first thing is convert it to its positive form.</p>



<p>Take the absolute value. Okay.</p>



<p>So we&#8217;re really just, you know, take positive form here,</p>



<p>and that&#8217;s just going to be positive 109.</p>



<p>Okay, no problem.</p>



<p>I&#8217;ll say start with negative 109, and then we&#8217;ll take the positive form 109.</p>



<p>Now we&#8217;ll convert it to binary.</p>



<p>Okay, this is not a video that teaches you how to convert to binary, so I&#8217;m just going</p>



<p>to try to do this in my head real fast here.</p>



<p>It&#8217;s going to be, let&#8217;s see, we got 8 bits, we&#8217;ll use just 8 bits to store the number,</p>



<p>and because it&#8217;s low enough and I don&#8217;t want to use that many bits, so it&#8217;s odd, so I can</p>



<p>add a 1 there, but maybe for now I should find the highest bit that is less than the</p>



<p>actual number.</p>



<p>So this is the 128 bit right here. So that&#8217;s going to be a zero. This is the 64 bits</p>



<p>I&#8217;m going to put a one there and I&#8217;m just going to say</p>



<p>Mmm, maybe like</p>



<p>This is like maybe not the smartest way to do it. I&#8217;ll say 109 minus 64</p>



<p>Because I put a one there and then 45 so now this is 32 that&#8217;s less than 45. So I&#8217;ll put a one there and</p>



<p>Then it&#8217;s going to be minus 40</p>



<p>So it goes from 45 to 13.</p>



<p>So then that was the 32.</p>



<p>Okay, so 128, 64, 32, and then 16.</p>



<p>Is 16 less than 13?</p>



<p>No, it&#8217;s not.</p>



<p>So we&#8217;ll put a zero here.</p>



<p>And then the next one is going to be just four.</p>



<p>Four is definitely less.</p>



<p>So I&#8217;ll put a one bit there.</p>



<p>And then I&#8217;ll subtract four.</p>



<p>And then one, two, four.</p>



<p>Oh, wait a minute.</p>



<p>One, two, four, eight.</p>



<p>wait a minute one two four eight sorry that was supposed to be subtracted uh subtracting eight</p>



<p>because that was the eight bit uh then i want to get five so here is the four bit so i put a one</p>



<p>there and then i&#8217;ll just put a one here because four plus five is equal to uh i&#8217;m sorry four plus</p>



<p>one is equal to five so let&#8217;s see um it is let me just double check here one</p>



<p>one let me just double check my conversion real fast it&#8217;s going to be</p>



<p>the one bit plus two four plus eight six thirty two plus thirty two plus sixty</p>



<p>four did I get one on nine yeah okay so I guess I did it right so convert to</p>



<p>binary and that&#8217;s going to be this the next thing we&#8217;ll do is we will invert the</p>



<p>bits I made a little edit jump here because I inverted the bits incorrectly</p>



<p>on the first try which is sad but hey it happens the next thing we&#8217;ll do is</p>



<p>but hey it happens the next thing we&#8217;ll do is we&#8217;ll invert the bits so basically you know we</p>



<p>take this original sequence here and i&#8217;ll just turn every single bit uh i&#8217;ll flip it i&#8217;ll flip</p>



<p>ones to zeros and zeros to ones so i&#8217;m going to go one zero zero one zero zero one zero okay so now</p>



<p>we have this number invert the bits then we just have to add one so we&#8217;ll add positive one to that</p>



<p>that it&#8217;s just going to be a one there at the end.</p>



<p>But sometimes that might not be the case</p>



<p>because what if we already had a one there</p>



<p>and we had to add one to that?</p>



<p>Well, we&#8217;d add one to the right side</p>



<p>and it would turn into a zero</p>



<p>and then it would carry a bit to the left.</p>



<p>That would become a zero</p>



<p>and then the carry bit would show up all the way over there.</p>



<p>So I just want you to be aware of the fact that</p>



<p>when you add two binary numbers together,</p>



<p>you have to be careful.</p>



<p>You have to add them the same way you would add decimal numbers.</p>



<p>For each digit&#8217;s position,</p>



<p>you have to add the two numbers together and then if they overflow then you just</p>



<p>kind of wrap around to the lowest number again subtracting you know the highest</p>



<p>value or sorry subtracting the base like in decimal if you add 9 and 9 the answer</p>



<p>is 18 but you&#8217;re not going to write 18 in that one position you&#8217;re going to</p>



<p>subtract the base which is 10 so it&#8217;ll actually be 8 and then you&#8217;ll carry the</p>



<p>plus nine is equal to eight carry the one right so we&#8217;ll do the same thing in binary we&#8217;ll say</p>



<p>if we ever get a one plus one when we&#8217;re adding the answer will be two but then we subtract the</p>



<p>base which is two so the answer is actually zero carry a one bit keep that in mind i&#8217;m just gonna</p>



<p>write it all out for you so you can kind of get a little bit of practice it&#8217;s important to to</p>



<p>practice this because it&#8217;s easy to get wrong i&#8217;m going to put a bunch of dashes up at the top to</p>



<p>and I&#8217;m going to say we&#8217;re going to add, you know, one number plus another number,</p>



<p>put a little plus symbol over there just to try and make sure we do it the right way.</p>



<p>Okay, so how do we add these?</p>



<p>Well, we&#8217;ll just go to the right side.</p>



<p>Zero plus one is one, no carry bit.</p>



<p>One plus zero is one, no carry bit.</p>



<p>Then we got a couple zeros here, no carry bit, of course.</p>



<p>One plus zero is one, no carry bit.</p>



<p>And then a couple zeros and then another one with no carry bit.</p>



<p>Okay, so, you know, we could have done that pretty easily, but</p>



<p>but well now we&#8217;re getting a taste for binary addition that might be harder later.</p>



<p>So we&#8217;ll just do that for now.</p>



<p>And now this is the two&#8217;s complement representation of negative 109.</p>



<p>I&#8217;ll say now we have negative 109 is equal to that.</p>



<p>leftmost number the most powerful sorry leftmost bit the most powerful bit is a one remember one</p>



<p>always indicates negative so when you&#8217;re looking at it if your leftmost bit turns out to be a zero</p>



<p>then you probably did something wrong or you had an overflow maybe um and again if we were going</p>



<p>to try to you know send this number into a two byte number or an eight byte number or whatever</p>



<p>uh then we would just have to pad with the sign bit so one two three four five six seven eight</p>



<p>help my brain so this was this is the way it would look in a two-byte number this is the way it would</p>



<p>look in a three-byte a four-byte and five six seven how many one two three four five six seven</p>



<p>okay one more this is what it would look like as an eight-byte number or a quad word 64-bit number</p>



<p>yeah okay so now we know how to do negative 109 okay so now let&#8217;s do a number that&#8217;s a little bit</p>



<p>negative 29. So let&#8217;s say convert, or how about represent negative 29 into</p>



<p>2&#8217;s complement. Okay. So first we, you know, first get the absolute value.</p>



<p>So just 29. And then we have to invert the, sorry, we have to get that into binary. So</p>



<p>next convert to binary. And I&#8217;m going to start with zeros, one, two, three, four, five, six,</p>



<p>1, 2, 3, 4, 5, 6, 7, 8.</p>



<p>For this video, remember, we&#8217;re choosing to use one byte integers.</p>



<p>But if you wanted to do a bigger one or you had to do a bigger one,</p>



<p>then just, you know, keep that in mind.</p>



<p>Okay, so 128 is not smaller than 29.</p>



<p>64 is not.</p>



<p>32 is not.</p>



<p>16 is, though.</p>



<p>So I&#8217;ll put a 16 bit there.</p>



<p>And I&#8217;ll just subtract 16 from 29.</p>



<p>29 minus 16.</p>



<p>Now we&#8217;ve got 13 left.</p>



<p>So 64, 32, 16.</p>



<p>six four thirty two sixteen eight okay so now I&#8217;m gonna put a one bit there and</p>



<p>I&#8217;m gonna subtract 8 from the remainder and then we got a five which is pretty</p>



<p>easy to do eight four and then a one so now we have well zero zero zero one one</p>



<p>one zero one that&#8217;s the binary number the positive or unsigned representation</p>



<p>representation. So now we&#8217;ll add one. Positive one. And let&#8217;s try to do this the right way so</p>



<p>that we can practice carry bits with addition a little bit. Notice how this one is already there</p>



<p>on the right side. So it&#8217;s going to, we&#8217;re going to have at least one carry bit for sure.</p>



<p>So then I&#8217;m going to go doop like that. And then I&#8217;m going to say that we have like, you know,</p>



<p>what is the result? Put a positive sign there. And then I&#8217;m going to put a bunch of dashes</p>



<p>my carry bits because I can I can forget that pretty easily. So the first thing is we add one</p>



<p>and one. The answer is two, but we can&#8217;t put the number two here because it&#8217;s binary. Instead we</p>



<p>need to subtract the base which is two. So two minus two is equal to zero, but then we have a</p>



<p>carry bit of one. So I&#8217;m going to put a one there. The first carry bit will stay as a dash for this</p>



<p>whole you know exercise because you&#8217;re not going to carry on to the first digit. So now we have</p>



<p>what would have been just zero plus zero now we have one plus zero plus zero so</p>



<p>that means this is going to be one and then the carry bit is just going to be</p>



<p>zero because we don&#8217;t actually carry anything so then we have zero plus one</p>



<p>plus zero so that&#8217;s going to be a one and then zero carry bit and then zero</p>



<p>one zero is just going to be one and then there&#8217;s going to be no carry bit</p>



<p>and then zero one zero again a one no carry bit because we didn&#8217;t actually</p>



<p>zero zero zero and then I&#8217;m just gonna put zeros here okay so now we have</p>



<p>successfully added I blew it totally blew it I always forget steps don&#8217;t</p>



<p>forget the steps this is a good lesson I&#8217;m gonna leave this in the video</p>



<p>because I want you to see that everybody makes mistakes and you got to practice</p>



<p>practice practice especially before you have to actually do this in real life or</p>



<p>or something like that.</p>



<p>Next, convert to binary.</p>



<p>Before you add one, I&#8217;m gonna just remove this.</p>



<p>Oh my gosh.</p>



<p>Next, flip the bits,</p>



<p>which is gonna be 1110010.</p>



<p>Okay.</p>



<p>So now we take this bit flipped number</p>



<p>and we will add one.</p>



<p>So that&#8217;s gonna be zero, zero, zero, zero, zero, zero, zero,</p>



<p>one, oh, it&#8217;s too easy.</p>



<p>Maybe I got excited and I thought,</p>



<p>excited and I thought, oh, it&#8217;s carry bit time.</p>



<p>But even though the last edition that I did was wrong because I forgot to carry</p>



<p>the or flip the bits, you still at least saw a little bit about how to carry the bits.</p>



<p>Right. OK, so it&#8217;s just going to be one.</p>



<p>Let me start from the right side.</p>



<p>One one zero zero zero one one one one one one.</p>



<p>Let me just double check here.</p>



<p>One one one zero zero zero.</p>



<p>OK, so I got that.</p>



<p>Now we have.</p>



<p>negative 29 in twos compliment. Again notice if we actually tried to add those numbers up to be</p>



<p>like an unsigned binary number they&#8217;re not really going to make sense because this is like 64 plus</p>



<p>32 plus 3. So what would that end up being? Let&#8217;s just double check here. 64 plus 32 plus 3, 99.</p>



<p>That&#8217;s not actually the number but the number is 29. So keep in mind you can&#8217;t just look at this</p>



<p>unless you&#8217;re like really, really practiced.</p>



<p>Okay, and again, notice that the number is 1 at the very left,</p>



<p>indicating that it&#8217;s a negative number.</p>



<p>Now, let&#8217;s look at how to subtract one number from another</p>



<p>using 2&#8217;s complement.</p>



<p>Okay, so what I want to do is I want to subtract,</p>



<p>let&#8217;s say, 29 from 109.</p>



<p>Okay, so let&#8217;s subtract, and I&#8217;ll just say 109 minus 29.</p>



<p>109 minus 29.</p>



<p>And how I would do that is basically I&#8217;ll start by just taking 109.</p>



<p>Let&#8217;s see, convert to binary.</p>



<p>So I&#8217;m just going to copy paste that number.</p>



<p>So 109 is this and then 29, take the positive version.</p>



<p>It is just, let&#8217;s see, before we flip the bits or anything,</p>



<p>let me make sure that I grab the right one.</p>



<p>Invert the bits, okay.</p>



<p>So positive 29 is this number.</p>



<p>Whoops.</p>



<p>is this number whoops let me put parentheses around that so it&#8217;s easy to tell and then I&#8217;ll</p>



<p>put a positive sign there like that maybe like that nope nope nope nope how about this okay</p>



<p>so now we have both of these numbers in positive form so now if we added 109 plus 29 that wouldn&#8217;t</p>



<p>negative positive 29 that would be what we wanted right because really if you&#8217;re subtracting</p>



<p>i&#8217;ll say aka</p>



<p>positive 29 plus negative 29 all we really need to do is um invert the 29 and then add the result</p>



<p>to 109 so that means we&#8217;ll we&#8217;ll turn positive 29 into negative 29 using two&#8217;s complement</p>



<p>through the steps again but basically put it there but basically you know that&#8217;s negative 29</p>



<p>so say positive 129 is equal to what i just put up here and then negative 29 is equal to</p>



<p>maybe i should do the parentheses again for clarity uh is equal to this okay so you can tell</p>



<p>that positive 29 is pretty pretty different from negative 29 but now we have</p>



<p>29 but now we have both of those numbers so let&#8217;s see 0 1 1 0 and then we&#8217;re ready to add okay all</p>



<p>we got to do is add them together next add them together maybe I should write the steps up here</p>



<p>negative 29 using twos complement and then next add them together so then I&#8217;m</p>



<p>going to copy paste the bits here and it&#8217;s going to be this plus this do a</p>



<p>positive plus sign just to remind ourselves that we are actually adding</p>



<p>and then I&#8217;m going to put a bunch of placeholders for sign bits up at the</p>



<p>top and now we&#8217;ll have a little bit more fun adding numbers together maybe I&#8217;ll</p>



<p>drag this down</p>



<p>Oh my god. Oh, there we go. Okay. So I&#8217;ll start with the one on the right, the position on the</p>



<p>right. That&#8217;s going to be one plus one equals two, but then that&#8217;s an overflow. So I&#8217;m going to</p>



<p>subtract the base. So it&#8217;s going to be zero. And then don&#8217;t forget to carry the one. Oh,</p>



<p>cool. More interesting. So we have one plus zero plus one. That&#8217;s going to be another two carry</p>



<p>two carry the one so it&#8217;s going to be zero and then carry the one again so i&#8217;m going to put the</p>



<p>carry bit up there and then again we have one plus one is equal to two so it&#8217;s going to be zero</p>



<p>carry the one again zero carry the one and then finally we don&#8217;t really have a carry bit</p>



<p>um so we&#8217;ll just have like a one and there&#8217;s there&#8217;s no carry so it&#8217;s going to be you know</p>



<p>carry a zero and then we add these two together so it&#8217;s going to be a zero carry the one and then</p>



<p>Now we have a three.</p>



<p>Oh, that&#8217;s kind of nice.</p>



<p>So this is an interesting edge case kind of.</p>



<p>One plus one plus one is three.</p>



<p>But if we subtract two, the base from it, you know, three minus two, it&#8217;s going to be one, not zero.</p>



<p>So it actually is going to be a one and then carry the one on top of that.</p>



<p>Then for here, let me space this over a little bit so that I can illustrate what&#8217;s going on a little bit better.</p>



<p>We&#8217;re going to have one plus zero plus one.</p>



<p>definitely going to be zero and then carry the one but there&#8217;s no bit where that carried one can</p>



<p>can show up on right so that one overflows it falls off the edge if this was a bigger number</p>



<p>then okay we you know if we had more bits to this number then sure we would just keep carrying over</p>



<p>over to the left but remember we said before that when we have a very big number let&#8217;s see</p>



<p>bits it&#8217;s just ones all the way to the side that will actually help us make sure that if our final</p>



<p>number is actually going to end up being positive that everything kind of like dominoes like carry</p>



<p>the one carry the one carry the one carry the one carry the one all the way until one of the ones</p>



<p>falls off think about it so anyway this one just is gone we don&#8217;t really care about it anymore</p>



<p>the result is going to be just only eight bits because that&#8217;s the number that we started with</p>



<p>bunch of zeros what is you know the final answer let&#8217;s just compute this</p>



<p>real fast to decimal so this is 128 and then 64 so it&#8217;s gonna be 64 plus not 32</p>



<p>but 16 so 64 plus 16 that&#8217;s gonna be oops 16 that&#8217;s gonna be 80 and now we</p>



<p>just have to ask ourselves again as like a final step to double check yourself to</p>



<p>what you&#8217;re doing and that you got it right is just punch up 109 minus 29 just to make sure</p>



<p>109 minus 29 whoops what happened here 109 minus</p>



<p>oh i think i stole my subtraction key for the annotator 109 minus 29 is 80</p>



<p>so again you know if you&#8217;re if you&#8217;re trying to like you know write something down to do some</p>



<p>you know taking an exam or something you definitely want to double check yourself in several ways</p>



<p>As you can tell from this video alone</p>



<p>I got one of these things wrong because I forgot to input the bits as a step before adding one</p>



<p>So you know your final step should be actually trying to add two numbers together or subtract numbers or whatever</p>



<p>You&#8217;re doing to make sure that you got the binary correct</p>



<p>So let&#8217;s see</p>



<p>Hmm</p>



<p>I guess maybe your first indication that the result was going to be positive would be that</p>



<p>there&#8217;s a zero there. And just, you know, as a sanity check, you look at the top and you&#8217;re like,</p>



<p>well, I was going to subtract a small number from a larger number. So the result should probably be</p>



<p>positive, right? Like 29 is like way lower than 109. So it should be positive, which means the</p>



<p>final result should have a zero at that leftmost position. Okay, so that&#8217;s two&#8217;s compliment,</p>



<p>two&#8217;s complement how to convert numbers from positive to negative in two&#8217;s complement you</p>



<p>know what the sign bit means and all that stuff and how to perform subtraction via two&#8217;s complement</p>



<p>i hope you enjoyed this video thank you for watching i hope you learned a little bit of</p>



<p>stuff and had a little bit of fun see you in the next video hey everybody thanks for watching this</p>



<p>video again from the bottom of my heart i really appreciate it i do hope you did learn something</p>



<p>If you could do me a please, a small little favor, could you please subscribe and follow this channel or these videos or whatever it is you do on the current social media website that you&#8217;re looking at right now.</p>



<p>It would really mean the world to me and it&#8217;ll help make more videos and grow this community.</p>



<p>So we&#8217;ll be able to do more videos, longer videos, better videos, or just I&#8217;ll be able to keep making videos in general.</p>



<p>So please do me a kindness and subscribe.</p>



<p>in the middle of the night and I just wake up because I know somebody</p>



<p>subscribed or followed. It just wakes me up and I get filled with joy. That&#8217;s</p>



<p>exactly what happens every single time. So you could do it as a nice favor to me</p>



<p>or you could you could troll me if you want to just wake me up in the middle</p>



<p>of the night just subscribe and then I&#8217;ll just wake up. I promise that&#8217;s what</p>



<p>will happen. Also if you look at the middle of the screen right now you</p>



<p>should see a QR code which you can scan in order to go to the website which I</p>



<p>think is also named somewhere at the bottom of this video and it&#8217;ll take you</p>



<p>you to my main website where you can just kind of like see all the videos I published and the</p>



<p>services and tutorials and things that I offer and all that good stuff and if you have a suggestion</p>



<p>for clarifications or errata or just future videos that you want to see please leave a comment or if</p>



<p>you just want to say hey what&#8217;s up what&#8217;s going on you know just send me a comment whatever I also</p>



<p>wake up for those in the middle of the night I get I wake up in a cold sweat and I&#8217;m like</p>



<p>it would really mean the world to me. I would really appreciate it. So again,</p>



<p>thank you so much for watching this video and enjoy the cool music as I fade</p>



<p>into the darkness, which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/master-twos-complement-convert-subtract-negative-binary-numbers/">Master Two&#8217;s Complement: Convert &amp; Subtract Negative Binary Numbers</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/master-twos-complement-convert-subtract-negative-binary-numbers/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Master Binary Scientific Notation (with Fun Examples!)</title>
		<link>https://www.NeuralLantern.com/how-to-master-binary-scientific-notation-with-fun-examples/</link>
					<comments>https://www.NeuralLantern.com/how-to-master-binary-scientific-notation-with-fun-examples/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 04 May 2025 06:24:32 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Conversions]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[base-2 notation]]></category>
		<category><![CDATA[binary fractions]]></category>
		<category><![CDATA[binary math]]></category>
		<category><![CDATA[binary numbers]]></category>
		<category><![CDATA[binary scientific notation]]></category>
		<category><![CDATA[coding for beginners]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[decimal to binary]]></category>
		<category><![CDATA[floating-point representation]]></category>
		<category><![CDATA[IEEE 754]]></category>
		<category><![CDATA[number systems]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scientific notation]]></category>
		<category><![CDATA[tech tutorials]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=99</guid>

					<description><![CDATA[<p>Master binary scientific notation with this fun, beginner-friendly guide! Learn to represent binary numbers with fractions for IEEE 754 and computer science. Clear examples show how to handle large and small numbers in base-2. Perfect for students and coders! Subscribe for more tech tutorials.</p>
<p>The post <a href="https://www.NeuralLantern.com/how-to-master-binary-scientific-notation-with-fun-examples/">How to Master Binary Scientific Notation (with Fun Examples!)</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="How to Master Binary Scientific Notation (with Fun Examples!)" width="1380" height="776" src="https://www.youtube.com/embed/GJKxf_-MZiY?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Ready to conquer binary scientific notation? Let’s make it fun and simple! In this video, I walk you through how to represent binary numbers with fractions in scientific notation—a must-know skill for computer science, programming, and understanding IEEE 754 floating-point representation. We start with the basics of scientific notation in decimal (think 8.54 × 10⁵), then dive into binary with clear, step-by-step examples. You’ll learn how to handle large and small binary numbers, move decimal points, and use base-2 like a champ. Whether you’re a student, coder, or just curious about how computers process numbers, this video has you covered!</p>



<p>I’ll show you practical examples, like converting huge binary numbers and tiny fractions, plus tips to avoid common mistakes (like mixing decimal and binary notation). By the end, you’ll be ready to tackle binary in IEEE 754 or impress your friends with your number-crunching skills. Subscribe for more tech tutorials, and hit that bell to stay updated! Visit my website (link below) for more resources, and leave a comment with your questions or video suggestions—I read every one! Let’s keep learning and having fun with tech together!</p>



<p>Introduction to Binary Scientific Notation 00:00:00<br>Purpose of Binary Representation 00:00:12<br>Overview of Scientific Notation 00:00:41<br>Rules for Scientific Notation 00:01:12<br>Decimal Scientific Notation Example 00:02:26<br>Practice with Large Decimal Number 00:04:12<br>Practice with Small Decimal Number 00:05:21<br>Binary Scientific Notation Concept 00:06:32<br>Binary Number Representation Rules 00:07:28<br>Large Binary Number Example 00:08:24<br>Small Binary Number Example 00:09:31<br>Mixing Binary and Decimal Notation 00:12:54<br>Pure Binary Scientific Notation 00:13:04<br>Connection to IEEE 754 00:13:48<br>Conclusion and Call to Action 00:14:21<br>Engagement and Website Promotion 00:15:32</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hey there! Let&#8217;s talk about representing binary numbers with fractions in scientific notation.</p>



<p>Why would you need to do this? Probably the best use that I can think of off the top of my head</p>



<p>is being able to represent binary numbers with fractions inside your machine in a format known</p>



<p>It&#8217;s just a crucial step before you can represent numbers inside your machine using IEEE 754.</p>



<p>Okay, so first off, let me just show you a little bit here about scientific notation.</p>



<p>So you probably have seen something like this before where it&#8217;s like 8.3873,</p>



<p>and then you&#8217;ll see like a multiplier times 10 to the fifth power, right?</p>



<p>I can&#8217;t really type this out very well, so maybe I could just draw it for a second, you know.</p>



<p>well so maybe I could just draw it for a second you know 8.54 times 10 to the fifth power right</p>



<p>that&#8217;s what I&#8217;m trying to convey but anyway so about scientific notation itself it&#8217;s standardized</p>



<p>so that it&#8217;s easier to use and that is you know it&#8217;s just like faster for everyone to understand</p>



<p>and there&#8217;s less confusion part of the standard is that you always want to have a number on the</p>



<p>that is between 1 and 9 inclusive. You don&#8217;t ever actually want to have a 0 there that would be bad.</p>



<p>You don&#8217;t want to have a 10 or anything greater that would also be bad. You just want to have</p>



<p>1, 2, 3, 4, 5, 6, 7, 8, 9 on the left side. And then on the fractional side,</p>



<p>you want to have a number that just kind of like helps you represent the entire</p>



<p>original number without losing precision. And then on the right side, you want a number,</p>



<p>a number, let&#8217;s say like x to the y power, where x is the base of the number system you&#8217;re working</p>



<p>in. So this is decimal. The base for decimal is 10. So we&#8217;re going to say 10 to the something</p>



<p>power. What is the power? The power here helps you understand how big or small the number on</p>



<p>the left really is. That&#8217;s kind of one of the benefits of scientific notation. It seems to</p>



<p>help you understand a little bit more of how big or how small a number is rather than exactly</p>



<p>than exactly down to you know the last digit what what is the number precisely so we could say for</p>



<p>now it focuses more on largeness or smallness than preciseness what number are we actually</p>



<p>representing with this in scientific notation well times 10 to the fifth power just means move the</p>



<p>decimal point over a certain number of times so uh you know that&#8217;s why we have 10 to the something</p>



<p>go left or right in a base 10 number you&#8217;re looking at a different number that has a factor</p>



<p>of 10 for its strength in either direction like multiply by 10 multiply by 10 multiply by 10</p>



<p>or divide by 10 divide by 10 divide by 10 in the other direction so this means we want to move the</p>



<p>decimal point five times to the right to increase the strength of the number times five so one two</p>



<p>three four five if we put the decimal number there then this is the number we were going to represent</p>



<p>number we were going to represent originally so if somebody says hey give me this number 838730</p>



<p>and put it in scientific notation then you your first instinct is to say all right let&#8217;s uh type</p>



<p>that number out and we&#8217;ll put like a dot zero there and it will just we&#8217;ll move the decimal</p>



<p>point over until there&#8217;s only one digit um and it&#8217;s a you know somewhere between a one and a nine</p>



<p>three four five times over in order to get the decimal point there so that</p>



<p>means it&#8217;s going to be this times 10 to the fifth power because we moved it over</p>



<p>five times and you can see that&#8217;s the original number that I showed you these</p>



<p>zeros at the very end they don&#8217;t actually mean anything so we can omit</p>



<p>them probably a smarter idea to omit them and that&#8217;s why we see numbers that</p>



<p>way okay so keep that in mind there&#8217;s only one digit let&#8217;s maybe do like</p>



<p>practice number here I have a couple practice numbers written down already</p>



<p>let&#8217;s see so we&#8217;ll start with this number a huge gigantic number just to</p>



<p>practice if we copy paste this down to the next line and then we decide all</p>



<p>right how many times do we need to move the decimal point to get the decimal</p>



<p>point right there so that the two is the first number remember one to nine</p>



<p>inclusive so I&#8217;ll just I&#8217;ll use two decimal points so I can count more</p>



<p>9, 10, 11, 12, 13.</p>



<p>So that means I did 13 moves.</p>



<p>I&#8217;ll put 13 right here so I don&#8217;t forget.</p>



<p>Times 10 to the 13th power.</p>



<p>And the 13 is positive because when we&#8217;re looking at the scientifically notated format</p>



<p>of the same number, you know, 2 point something is way smaller than the original number.</p>



<p>So we want the scientifically notated format or form to get bigger in order to reach this</p>



<p>number.</p>



<p>in order to reach this number so that means 10 times sorry times 10 to a positive number positive</p>



<p>means it&#8217;ll be bigger in its original form okay so now let&#8217;s do another practice number</p>



<p>let&#8217;s do a number that&#8217;s really really really small like you&#8217;re inside of inner space or</p>



<p>something so we start up with this number and we still want to have a number between</p>



<p>rewrite it here I really want to have eight point something because that&#8217;s the first number that&#8217;s</p>



<p>bigger than zero that I can see so again I&#8217;m using two decimal points so that it&#8217;s easy for me to</p>



<p>count I&#8217;m going to go one two three four five six seven I had to move it seven times so it&#8217;s going</p>



<p>to be negative seven is going to be the exponent so you know raised something raised to the negative</p>



<p>seven it&#8217;s still going to be 10 to the negative seven that I multiply it by so then I&#8217;ll say get</p>



<p>And now this is the same number represented in scientific notation.</p>



<p>It should have all the same digits.</p>



<p>The decimal point basically should just be moved.</p>



<p>Of course, you know, when you represent in scientific notation,</p>



<p>depending on what standard you&#8217;re working with,</p>



<p>you might actually omit some of the numbers at the very end of the fraction here.</p>



<p>But that&#8217;s why we say this is kind of more to impress upon you the smallness or largeness of a number</p>



<p>rather than represent the number exactly precisely.</p>



<p>okay so we got that two practices in there how can we do this same exact concept in binary</p>



<p>well keep in mind in binary binary is a base two number this video is not about binary conversion</p>



<p>as a whole number or binary with fraction let&#8217;s just pretend that we already know how to do that</p>



<p>and we have a binary number to start off with so let me grab my example number here</p>



<p>have some kind of a binary number with a fraction, which you can do if you don&#8217;t understand how to do</p>



<p>this part yet from decimal with a fraction to binary with a fraction or back and forth.</p>



<p>See my other videos. For now, we&#8217;ll assume you can do this. So how can we get this in scientific</p>



<p>notation? So the first thing we have to understand is that it&#8217;s going to be, you know, some number</p>



<p>right because that was the format we used before the number should only start with a one it should</p>



<p>never even start with a zero remember in binary we can only use ones and zeros before i said here</p>



<p>let me just show you this real fast again before i said the starting number has to be one through</p>



<p>nine inclusive that was because in decimal we have zero one two three four five six seven eight nine</p>



<p>be only use you know one two three five six seven eight nine so but in binary um i&#8217;ll put like</p>



<p>a character set like the available characters we can use to represent the numbers in decimal</p>



<p>so in binary the care set that we can use is just you know a zero and a one only but the same rule</p>



<p>the one so that means the first number always has to be one it has to be always one dot something</p>



<p>for our purposes to represent the same number in scientific notation so it&#8217;s going to be</p>



<p>this and obviously that one has to be it it cannot ever be a zero so i&#8217;m going to put the</p>



<p>decimal point there uh and then i&#8217;m just going to count like how much did i actually move the</p>



<p>seven eight nine ten eleven twelve thirteen fourteen fifteen six just fifteen just fifteen not</p>



<p>sixteen so i&#8217;m going to put times something to the fifteen power and remove that other decimal</p>



<p>point and then the base is two so it&#8217;s going to be two to the fifteenth power</p>



<p>so now maybe i should move that up a little bit</p>



<p>gigantic number uh in scientific notation it&#8217;s going to look a little smaller but then the times</p>



<p>base to the 15th power is going to help us understand how big it is oh it&#8217;s like pretty big</p>



<p>let&#8217;s do the same thing backwards let&#8217;s say that we wanted to start off with a very very small</p>



<p>number so it&#8217;s like you know a zero point something in binary so you can imagine if this is like one</p>



<p>256 that&#8217;s probably going to be a number that&#8217;s no bigger than or just like slightly bigger than</p>



<p>256 so it&#8217;s going to be like kind of a small number right well we&#8217;ll do the same thing just</p>



<p>copy to another line and then make sure that the decimal point sits in a place where there&#8217;s always</p>



<p>a one at the start</p>



<p>and then just count the number of times you moved</p>



<p>number of times you moved the number oh I guess before we would have possibly</p>



<p>deleted numbers on the right if we were gonna reduce precision in this case</p>



<p>after we count the numbers we&#8217;re gonna remove everything to the left of the one</p>



<p>so that the one is in the first position and I&#8217;ll just go ahead and do it okay so</p>



<p>how many times do we move it one two three four five six seven eight that&#8217;s</p>



<p>eight times so I&#8217;m gonna put an eight there just to remind myself that there</p>



<p>will be an eight I&#8217;ll remove all the stuff at the beginning that doesn&#8217;t</p>



<p>all the stuff at the beginning that doesn&#8217;t matter anymore and it&#8217;s going to be times two because</p>



<p>that&#8217;s our base to the eighth power but the original number is a lot smaller than the</p>



<p>scientifically notated number looks so that means we have to put a negative eight because remember</p>



<p>when you say times let me just show you this on a calculator when we say let&#8217;s let&#8217;s go back to</p>



<p>fifth power then you know that we&#8217;re just basically adding four zeros right so</p>



<p>like we have five total zeros so we&#8217;re adding four zeros to the ten but if we</p>



<p>did to the negative five power we&#8217;re gonna be like dividing it by ten a bunch</p>



<p>of times so instead of multiplying it by ten for a total of five times we&#8217;re</p>



<p>gonna divide by ten so then the number gets really really really small so that</p>



<p>means when we say two to the negative eight power we&#8217;re gonna be dividing it</p>



<p>We&#8217;re going to be dividing it by two that many times.</p>



<p>And so we end up with a really, really, really small number.</p>



<p>Isn&#8217;t that what I kind of said?</p>



<p>Let&#8217;s see.</p>



<p>I mean, like, not exactly, but, you know, it&#8217;s like 0.003 and then some numbers after that.</p>



<p>Didn&#8217;t I say one divided by 256?</p>



<p>It&#8217;s 0.003 and then some numbers.</p>



<p>So this number is just a little bit bigger than 0.003.</p>



<p>Nine.</p>



<p>Let&#8217;s see how much bigger it is.</p>



<p>bigger it is point three six two five what</p>



<p>oh because i&#8217;m not i&#8217;m not including the the part on the left that we will multiply it by so if i</p>



<p>you know if i did some like binary up here and i was in binary mode then it would probably make</p>



<p>more sense it ended up being exactly the same exact number that&#8217;s why i was confused because</p>



<p>if we just type that part on the right side then it really is going to be one over 256.</p>



<p>Anyway, long story short, we have this number here, the fractional part, and then we&#8217;re</p>



<p>going to multiply it by two to the something power.</p>



<p>Notice something in particular that I&#8217;m doing, which is probably my mistake, but I kind of</p>



<p>like doing it this way.</p>



<p>Notice how the left part is in binary and the right part is in decimal.</p>



<p>There&#8217;s no number two in binary or no number eight in binary.</p>



<p>numbers like this to scientific notation so that you can convert a binary number to i triple e</p>



<p>floating point number this is as far as you really need to go but if you truly want to represent a</p>



<p>binary number in scientific notation then you should also convert all of the relevant parts</p>



<p>so how do we represent uh the number two in binary it&#8217;s going to be one zero how do we represent the</p>



<p>number eight in binary it&#8217;s going to be one two four eight it&#8217;s going to be that so uh you know</p>



<p>big number times 10 in binary is still the number two to the something power the negative 1000 in</p>



<p>binary power is going to be you know eight the negative eight power so this is great if you just</p>



<p>want to write an entire number in scientific notation but uh you know in probably my next</p>



<p>video when we talk about ieee 754 notation this is as far as you really need to go</p>



<p>eight number into a a whole number in binary and then putting that somewhere but so just</p>



<p>forget about this for now keep in mind this is how far you have to go if you want to go to ieee</p>



<p>if you only want to be in pure binary then this is what it would look like</p>



<p>okay that&#8217;s it uh i think that&#8217;s all the example i have for you today in this video thank you so</p>



<p>much for watching i hope you learned a little bit and had a little bit of fun see you in the next</p>



<p>video</p>



<p>Hey everybody!</p>



<p>Thanks for watching this video again from the bottom of my heart.</p>



<p>I really appreciate it.</p>



<p>I do hope you did learn something and have some fun.</p>



<p>If you could do me a please, a small little favor, could you please subscribe and follow</p>



<p>this channel or these videos or whatever it is you do on the current social media website</p>



<p>that you&#8217;re looking at right now.</p>



<p>It would really mean the world to me and it&#8217;ll help make more videos and grow this community.</p>



<p>better videos or just I&#8217;ll be able to keep making videos in general so please</p>



<p>do do me a kindness and and subscribe you know sometimes I&#8217;m sleeping in the</p>



<p>middle of the night and I just wake up because I know somebody subscribed or</p>



<p>followed it just wakes me up and I get filled with joy that&#8217;s exactly what</p>



<p>happens every single time so you could do it as a nice favor to me or you could</p>



<p>you control me if you want to just wake me up in the middle of the night just</p>



<p>subscribe and then I&#8217;ll just wake up I promise that&#8217;s what will happen also if</p>



<p>If you look at the middle of the screen right now, you should see a QR code, which you can scan in order to go to the website, which I think is also named somewhere at the bottom of this video.</p>



<p>And it&#8217;ll take you to my main website where you can just kind of like see all the videos I published and the services and tutorials and things that I offer and all that good stuff.</p>



<p>And if you have a suggestion for clarifications or errata or just future videos that you want to see, please leave a comment.</p>



<p>or if you just want to say hey what&#8217;s up what&#8217;s going on you know just send me a comment whatever</p>



<p>i also wake up for those in the middle of the night i get i wake up in a cold sweat and i&#8217;m like</p>



<p>it would really it really mean the world to me i would really appreciate it so again thank you</p>



<p>so much for watching this video and um enjoy the cool music as as i fade into the darkness</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/how-to-master-binary-scientific-notation-with-fun-examples/">How to Master Binary Scientific Notation (with Fun Examples!)</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/how-to-master-binary-scientific-notation-with-fun-examples/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Hex to Decimal Made Easy: Fun &#038; Simple Conversion Guide!</title>
		<link>https://www.NeuralLantern.com/hex-to-decimal-made-easy-fun-simple-conversion-guide/</link>
					<comments>https://www.NeuralLantern.com/hex-to-decimal-made-easy-fun-simple-conversion-guide/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Fri, 02 May 2025 09:23:46 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Conversions]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[beginner coding]]></category>
		<category><![CDATA[binary to decimal]]></category>
		<category><![CDATA[coding for beginners]]></category>
		<category><![CDATA[coding guide]]></category>
		<category><![CDATA[computer science basics]]></category>
		<category><![CDATA[computer science tutorial]]></category>
		<category><![CDATA[hex to decimal]]></category>
		<category><![CDATA[hexadecimal to decimal]]></category>
		<category><![CDATA[hexadecimal tutorial]]></category>
		<category><![CDATA[learn to code]]></category>
		<category><![CDATA[number conversion]]></category>
		<category><![CDATA[number systems]]></category>
		<category><![CDATA[programming tutorial]]></category>
		<category><![CDATA[tech education]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=95</guid>

					<description><![CDATA[<p>Learn to convert hexadecimal to decimal with this fun, easy guide! Perfect for beginners in coding and computer science. #HexToDecimal #LearnToCode</p>
<p>The post <a href="https://www.NeuralLantern.com/hex-to-decimal-made-easy-fun-simple-conversion-guide/">Hex to Decimal Made Easy: Fun &amp; Simple Conversion Guide!</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Hex to Decimal Made Easy: Fun &amp; Simple Conversion Guide!" width="1380" height="776" src="https://www.youtube.com/embed/yDk-fB52i0A?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Confused by hexadecimal numbers? Don’t worry! This fun, step-by-step guide makes converting hex to decimal super easy, even for beginners. With clear examples and a chill vibe, you’ll master this computer science skill in no time. Perfect for students, coders, or anyone curious about number systems. Hit subscribe for more coding tutorials, and check out our site for extra resources! #HexToDecimal #CodingForBeginners #ComputerScience #LearnToCode</p>



<p>Introduction to Hexadecimal Conversion 00:00:00<br>Purpose of Conversion 00:00:11<br>Number System Basics 00:00:39<br>Hexadecimal Explanation 00:01:12<br>Converting Hex to Decimal 00:01:59<br>First Example Setup 00:02:35<br>Decimal Place Value Recap 00:03:02<br>Hexadecimal Place Value 00:05:14<br>Formula for Conversion 00:05:43<br>Translating Hex Letters 00:08:17<br>First Example Calculation 00:09:51<br>Second Example Introduction 00:11:14<br>Second Example Conversion 00:11:58<br>Second Example Result 00:13:11<br>Conclusion and Call to Action 00:14:00</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hello there. Let&#8217;s talk about converting hexadecimal to decimal.</p>



<p>So why would you do this? Of course, sometimes in computer science and other realms, you may be</p>



<p>faced with a number that looks like this, and it&#8217;s got some letters in there, and it&#8217;s weird,</p>



<p>and you&#8217;re thinking, oops, not a V. That wouldn&#8217;t work. Not a G. And you&#8217;re thinking like, what does</p>



<p>what does this number mean in decimal well this is a number that is real and we can just change</p>



<p>the way it&#8217;s represented uh to decimal so that we can understand what it is so just like a quick</p>



<p>recap if you haven&#8217;t watched my other videos yet uh in decimal we have a base 10 system which just</p>



<p>basically means we have these characters zero one two three four five six seven eight nine there</p>



<p>base is 10. In binary, of course, we have base two, which is just, you know, we have a zero and a one</p>



<p>because in the computer, which is why we learn binary, we just have on and off basically for</p>



<p>every single, you know, part of the computer. There&#8217;s just like a certain voltage or there&#8217;s</p>



<p>not a certain voltage and that&#8217;s it. And then for hexadecimal, which is a way to represent the same</p>



<p>numbers, but just in a more compact way. It&#8217;s a little bit more compact than decimal. It&#8217;s a lot</p>



<p>than binary we can say that this is base 16 which means we have 16 total characters that we can work</p>



<p>with zero one two three four five six seven eight nine and once we run out of numbers we just start</p>



<p>using letters so a b c d e f so there are 16 total characters if we include the zero which means we</p>



<p>So that&#8217;s the basics of you know the number basis let&#8217;s uh let&#8217;s work out how to convert a hex</p>



<p>number to decimal. So I&#8217;m going to say ox because in hex when you write down a hex number you should</p>



<p>usually put ox in front of it unless the program you&#8217;re working with doesn&#8217;t understand that but</p>



<p>usually especially for a human reader you should do it this way. So I&#8217;m going to just type like a</p>



<p>few random maybe I have to I have to keep the number small because hex will explode it&#8217;ll be</p>



<p>not careful. So I&#8217;m going to put like a I don&#8217;t know, maybe a few decimal numbers there or a few</p>



<p>like digits that are zero to nine, then I&#8217;ll just to make it more interesting, I&#8217;ll put some letters</p>



<p>in there. How about like an E there? And then I don&#8217;t know, like, we&#8217;ll do a B there. Okay, so</p>



<p>how many do I have? 12341234? How about we get rid of? Now, let&#8217;s go for it. This is going to be an</p>



<p>So this is our starting number hexadecimal. What we need to do is understand that, well,</p>



<p>a recap if you haven&#8217;t watched my other videos yet. In decimal we have, let&#8217;s say, 0, 1, 2, 3,</p>



<p>4, 5, 6. You know that the first digit has a strength of 1. You multiply 6 by 1 to understand</p>



<p>the real power of that 6. For the 5, you know that it has a power of 10 or a strength of 10</p>



<p>10 because it&#8217;s the next digit over you know to the left same thing for the four it&#8217;s like got a</p>



<p>strength of 100 and so every time you move to the left the strength of the digit increases by a</p>



<p>factor of 10. why does it increase by a factor of 10 because decimal is base 10 because we have 10</p>



<p>possible digits we can represent for each character okay so by the time we get to that</p>



<p>left, we have a strength of 100,000. So, you know, if you wanted to really understand 100,000,</p>



<p>if you really wanted to understand, you know, how powerful, let me, let me give some spacing here.</p>



<p>So this feels better. Okay. If you really wanted to understand like, you know, what is the strength?</p>



<p>What is like the actual value of this digit right here? You&#8217;re imagining this is like 100,000.</p>



<p>this digit here you&#8217;re imagining that this is two of ten thousand you know two times ten thousand</p>



<p>and so forth so uh uh just like another recap the first digit is really 10 to the zero power</p>



<p>like in terms of the strength because if you multiply um let me pin this to the top</p>



<p>if you multiply you know 10 to the something power and you start at zero with the most</p>



<p>the weakest digit 10 to the zero power gives a strength of one and then every time you move over</p>



<p>to the left you just increase the exponent there by one so 10 to the first power is going to be 10</p>



<p>that&#8217;s what that five has got so it&#8217;ll be five times 10 to give us an understanding of how you</p>



<p>know powerful that digit is move one over to the left it&#8217;s 10 to the second power so that&#8217;s 100</p>



<p>move one over to the left it&#8217;s 10 to the third power and so forth until we get to 10 to the fifth</p>



<p>1 times 10 to the fifth power to understand how powerful that is so we can do the same exact thing</p>



<p>with hexadecimal except instead of raising 10 to a power we raise 16 to a power because hexadecimal</p>



<p>is base 16 whereas decimal is base 10. so that means this e is is uh you know 10 to the or sorry</p>



<p>16 to the zero power and then that 3 is 16 to the 1 power and that f is 16 to the 2 power and so</p>



<p>16 to the 2 power and so forth so first what we should do is let&#8217;s write out a</p>



<p>formula which won&#8217;t work in a calculator because we&#8217;re going to put some letters</p>



<p>in there and then later we&#8217;ll translate the letters to actual values so we&#8217;ll</p>



<p>start off with the e we&#8217;ll say e times 16 to the something power it&#8217;s going to be</p>



<p>16 to the zero power okay so then the next digit is 3 so 3 times 16 to the</p>



<p>And then the next thing is going to be F times 16 to the second power.</p>



<p>And just as a reminder here, I&#8217;m starting with zero with the smallest digit.</p>



<p>And I&#8217;m just working my way up in steps of one.</p>



<p>So it&#8217;s zero power or raised to zero and raised to one and raised to two and just so forth all the way to the left.</p>



<p>That number will just keep increasing by one.</p>



<p>The exponent will increase by one.</p>



<p>times 16 to the third power do it again um one times 16 to the fourth power do it again</p>



<p>um d times 16 to the fourth power oh what did i do did i erase something</p>



<p>0, 1, 2, 3, 4, 5.</p>



<p>Oh, that was supposed to be a 5.</p>



<p>Okay, maybe it&#8217;s good that I thought I made a mistake</p>



<p>because that drew my attention to the bad exponent.</p>



<p>Okay, so after the D is a B.</p>



<p>B times 16 to the 6th power.</p>



<p>And then one more.</p>



<p>We&#8217;ll say 6 times 16 to the 7th power.</p>



<p>And then another one.</p>



<p>A times 16 to the, whoops, to the eighth power.</p>



<p>And another one.</p>



<p>One times 16 to the ninth power.</p>



<p>Ninth power.</p>



<p>Okay.</p>



<p>So just double check your work real fast.</p>



<p>You know, because I make typos all the time and I get things wrong all the time.</p>



<p>So just double check.</p>



<p>Zero, one, two, three, four, five, six, seven, eight, nine.</p>



<p>It&#8217;s sequential.</p>



<p>Double check the digits.</p>



<p>6 b d 1 3 f 3 e okay so i got that right i&#8217;m not going to erase my work because if i end up screwing</p>



<p>up the next part oh man is it going to be a hassle to correct so i&#8217;m just going to copy paste it here</p>



<p>and then i&#8217;m going to start translating the letters to numbers anytime you see a number here like one</p>



<p>time something it&#8217;s just one but every time you see a letter you have to translate that into</p>



<p>in decimal. Remember in hex, we&#8217;ll say, what can I do?</p>



<p>I can say A, B, C, D, E, F.</p>



<p>And I can say that the A is worth 10.</p>



<p>The B is worth 11.</p>



<p>The C is worth 12.</p>



<p>And the D is worth 13.</p>



<p>The E is worth 14 and the F is worth 15.</p>



<p>Well, maybe I should do the other numbers too.</p>



<p>five, six, seven, eight, nine,</p>



<p>just so we have a visual reminder</p>



<p>of like what we&#8217;re even looking at.</p>



<p>And I won&#8217;t write down what the digits are worth</p>



<p>because they&#8217;re worth themselves, right?</p>



<p>So like zero through nine, it&#8217;s just worth zero through nine.</p>



<p>So now that we have this little translation table up here,</p>



<p>anytime we see a letter,</p>



<p>we can just translate it very quickly to the decimal value.</p>



<p>So A is worth 10, we&#8217;ll put a 10 there.</p>



<p>Maybe I&#8217;ll add some spacing so that this continues to line up.</p>



<p>I see a B here, so the B is gonna be worth 11,</p>



<p>11 add another space so it lines up i&#8217;m running out of room but i&#8217;ll try the d is worth 13 add</p>



<p>another space so it lines up and then the f is worth 15 add another space so it lines up the e</p>



<p>is worth 14 so i&#8217;ll add another space so it lines up okay let me just double check my work here a b d</p>



<p>So now I&#8217;ve got like a big formula that I wrote out.</p>



<p>I can literally now, I mean, you can do this in your head if you&#8217;re like a crazy genius,</p>



<p>but I&#8217;m just going to paste this into a calculator and hit enter.</p>



<p>And this is the number that we had originally in hex.</p>



<p>Maybe I&#8217;ll put commas here to make things more fun.</p>



<p>I don&#8217;t know.</p>



<p>You don&#8217;t really need to do that, but I&#8217;m going to.</p>



<p>So for me, it&#8217;s easier to read.</p>



<p>this is uh like 113 trillion 478 no wait that&#8217;s a million and that&#8217;s a bill okay so 113 mil a</p>



<p>billion 478 million 25 022. let me punch up my personal calculator here to make sure that i&#8217;m</p>



<p>getting this right i&#8217;m not going to show this on the screen because i&#8217;ve just got this up</p>



<p>on my host machine bet you didn&#8217;t know i&#8217;m inside of vm right now surprised you didn&#8217;t know that</p>



<p>decimal and the number is supposed to be 113478025022 okay so we did this right we now know how</p>



<p>to convert from hexadecimal to decimal and it&#8217;s pretty awesome right okay let&#8217;s do another number</p>



<p>one that is not quite as hard let&#8217;s see how many digits do we have here one two three i think we</p>



<p>5, 6, 7, 8, 9, 10.</p>



<p>Yeah, okay, we had 10.</p>



<p>Let&#8217;s do a five-digit hex number.</p>



<p>Okay, maybe I&#8217;ll copy…</p>



<p>I&#8217;ll copy just this table at the top</p>



<p>since you don&#8217;t need it anymore,</p>



<p>but I&#8217;m going to need it to do my calculations.</p>



<p>So we&#8217;ll do 1, 2, 3, 4, 5,</p>



<p>and I&#8217;ll just start randomly changing</p>



<p>some of these numbers.</p>



<p>Like an 8 over here, and how about like a 2?</p>



<p>So I&#8217;ve got five numbers.</p>



<p>This is OX.</p>



<p>I&#8217;m going to say this is a hexadecimal number.</p>



<p>Kind of ambiguous if we tell the reader this is a hex number,</p>



<p>but then we put OX.</p>



<p>Kind of don&#8217;t really need to tell them that it&#8217;s hex</p>



<p>because OX tells you it&#8217;s hex.</p>



<p>It&#8217;s not even part of the value.</p>



<p>So let&#8217;s get on with it.</p>



<p>I&#8217;ll start by just doing 8 times 16 to the something power,</p>



<p>which is going to be 0 for that first position.</p>



<p>the power as we go to the left so it&#8217;s going to be 1 times 16 to the first power and then it&#8217;s</p>



<p>going to be f times 16 to the second power and then it&#8217;s going to be 2 times 16 to the third</p>



<p>power oh no my thoughts are wandering i think i&#8217;m getting bored of recording this video i&#8217;m starting</p>



<p>to the fourth power but honestly why couldn&#8217;t they end up together so and</p>



<p>then I think one two three four five okay so that&#8217;s five digits a to f one</p>



<p>eight a to f one eight all right zero one two three four just to make sure</p>



<p>that I got my exponents right copy paste it so I don&#8217;t have to repeat my work if</p>



<p>I get something wrong I&#8217;m gonna translate the letters into numbers so a</p>



<p>becomes 10 f becomes 15 and the other numbers are fine as is I can just copy</p>



<p>fine as is I can just copy paste this whole thing stick it into a calculator and now I know that</p>



<p>this number is actually 667 416 with a little comma in there don&#8217;t put commas if you are taking an</p>



<p>exam somewhere if you&#8217;re watching my video to help with your exam because most most likely the exam</p>



<p>that you&#8217;re taking will not accept a comma it&#8217;s not been pre-programmed for a comma I don&#8217;t know</p>



<p>If you start typing numbers and a comma just shows up, then it probably was programmed for a comma.</p>



<p>But don&#8217;t assume it might be a string match and not a numeric match.</p>



<p>So be careful out there.</p>



<p>Be careful.</p>



<p>So 667-416.</p>



<p>Let me punch this into my personal calculator just to make sure I got this right and I don&#8217;t have to issue an errata.</p>



<p>667-416.</p>



<p>All right.</p>



<p>We&#8217;ve done it.</p>



<p>We know how to convert hexadecimal numbers into decimal numbers.</p>



<p>Thank you so much for watching this video. I hope you enjoyed it and had a little bit of fun and</p>



<p>learned a little bit of stuff. I&#8217;ll see you in the next video. Hey everybody, thanks for watching</p>



<p>this video again from the bottom of my heart. I really appreciate it. I do hope you did learn</p>



<p>something and have some fun. If you could do me a please, a small little favor, could you please</p>



<p>subscribe and follow this channel or these videos or whatever it is you do on the current social</p>



<p>It would really mean the world to me and it&#8217;ll help make more videos and grow this community.</p>



<p>So we&#8217;ll be able to do more videos, longer videos, better videos, or just I&#8217;ll be able to keep making videos in general.</p>



<p>So please do me a kindness and subscribe.</p>



<p>You know, sometimes I&#8217;m sleeping in the middle of the night and I just wake up because I know somebody subscribed or followed.</p>



<p>It just wakes me up and I get filled with joy.</p>



<p>That&#8217;s exactly what happens every single time.</p>



<p>So you could do it as a nice favor to me or you could troll me if you want to just wake me up in the middle of the night.</p>



<p>Just subscribe.</p>



<p>just wake me up in the middle of the night just subscribe and then I&#8217;ll just</p>



<p>wake up I promise that&#8217;s what will happen also if you look at the middle of</p>



<p>the screen right now you should see a QR code which you can scan in order to go</p>



<p>to the website which I think is also named somewhere at the bottom of this</p>



<p>video and it&#8217;ll take you to my main website where you can just kind of like</p>



<p>see all the videos I published and the services and tutorials and things that I</p>



<p>for clarifications or errata or just future videos that you want to see please leave a comment or if</p>



<p>you just want to say hey what&#8217;s up what&#8217;s going on you know just send me a comment whatever I also</p>



<p>wake up for those in the middle of the night I get I wake up in a cold sweat and I&#8217;m like</p>



<p>it would really it really mean the world to me I would really appreciate it so again thank you so</p>



<p>much for watching this video and enjoy the cool music as as I fade into the darkness which is</p>



<p>the darkness which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/hex-to-decimal-made-easy-fun-simple-conversion-guide/">Hex to Decimal Made Easy: Fun &amp; Simple Conversion Guide!</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/hex-to-decimal-made-easy-fun-simple-conversion-guide/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Convert Decimal to Hexadecimal: Fun &#038; Easy Guide for Beginners</title>
		<link>https://www.NeuralLantern.com/how-to-convert-decimal-to-hexadecimal-fun-easy-guide-for-beginners/</link>
					<comments>https://www.NeuralLantern.com/how-to-convert-decimal-to-hexadecimal-fun-easy-guide-for-beginners/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 13 Apr 2025 00:54:33 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Conversions]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[beginner programming]]></category>
		<category><![CDATA[binary to hex]]></category>
		<category><![CDATA[coding for beginners]]></category>
		<category><![CDATA[coding tips]]></category>
		<category><![CDATA[coding tutorial]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[decimal to hexadecimal]]></category>
		<category><![CDATA[hex explained]]></category>
		<category><![CDATA[hexadecimal conversion]]></category>
		<category><![CDATA[learn to code]]></category>
		<category><![CDATA[math for coding]]></category>
		<category><![CDATA[number systems]]></category>
		<category><![CDATA[programming basics]]></category>
		<category><![CDATA[tech tutorials]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=88</guid>

					<description><![CDATA[<p>"Hexadecimal uses 0-9 and A-F to represent 16 values, making it shorter than binary. Learn to convert decimal to hex with this fun, step-by-step guide!</p>
<p>The post <a href="https://www.NeuralLantern.com/how-to-convert-decimal-to-hexadecimal-fun-easy-guide-for-beginners/">How to Convert Decimal to Hexadecimal: Fun &amp; Easy Guide for Beginners</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-wp-embed is-provider-rumble-com wp-block-embed-rumble-com"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" title="How to Convert Decimal to Hexadecimal: Fun &amp; Easy Guide for Beginners" src="https://rumble.com/embed/v6ptsuf/#?secret=pWTtkdDlLf" data-secret="pWTtkdDlLf" width="1000" height="563" frameborder="0"></iframe>
</div></figure>



<p>Want to master decimal-to-hexadecimal conversion? Join me in this fun, beginner-friendly tutorial where we break it down with clear examples?like turning 223 into 0xDF! From number systems to handy calculator tricks, I?ll guide you step-by-step, no stress. Bonus: my dog makes a cameo! Perfect for coding newbies or anyone curious about hex. Subscribe for more easy tech tutorials, and let me know what you want to learn next! #DecimalToHex #CodingBasics #LearnToCode</p>



<p>Introduction 00:00:00<br>Number Systems Overview 00:00:12<br>Decimal vs. Hexadecimal 00:00:39<br>Hexadecimal Digits Explained 00:01:06<br>Conversion Process Introduction 00:01:40<br>First Conversion Example Start 00:02:10<br>Handling Remainders 00:02:38<br>Dog Interruption 00:03:16<br>Continuing First Conversion 00:03:43<br>Finalizing First Conversion 00:06:04<br>Reversing Digits Order 00:06:24<br>Mapping Numbers to Hex Letters 00:07:34<br>Verifying First Conversion 00:08:48<br>Hexadecimal Prefix Importance 00:10:57<br>Second Conversion Example (223) 00:11:34<br>Third Conversion Example (2816) 00:13:32<br>Hex and Binary Relationship 00:14:56<br>Padding Zeros in Hex 00:16:07<br>Video Conclusion 00:16:58</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hello there.</p>



<p>Let&#8217;s talk about converting decimal to hexadecimal.</p>



<p>Hopefully you&#8217;ve watched my other videos by now, but basically we have different number</p>



<p>systems, number bases that we can use.</p>



<p>We have decimal, which is a base 10.</p>



<p>which is base 10 or sorry base 16.</p>



<p>We can basically convert back and forth between all of these systems.</p>



<p>We can represent the exact same number just in different ways.</p>



<p>Just as a quick refresher.</p>



<p>Decimal, we can have characters that are 0 through 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.</p>



<p>That&#8217;s 10 total characters.</p>



<p>That&#8217;s why it&#8217;s base 10.</p>



<p>In binary, we have, you know, just characters 0 and 1.</p>



<p>characters 0 and 1 and in hexadecimal it&#8217;s meant to compact the representation a little bit it has</p>



<p>more characters or more possible characters per digit than decimal so the number is going to be</p>



<p>a little bit shorter usually unless it&#8217;s like very very small than decimal and it&#8217;ll be a lot shorter</p>



<p>than the same number in binary so in hexadecimal we start off with 0 1 2 3 4 5 6 7 8 9</p>



<p>three, four, five, six, seven, eight, nine.</p>



<p>And then to get the remaining digits, we just go A, B, C, D, E, F.</p>



<p>So we have this many characters.</p>



<p>It&#8217;s 16 total characters.</p>



<p>We can represent a number between 0 and 15.</p>



<p>So that&#8217;s a difference between, you know, hexadecimal and decimal.</p>



<p>Now let&#8217;s learn how to actually convert.</p>



<p>So I&#8217;m going to start off with a number.</p>



<p>I&#8217;m just going to type like a random number here.</p>



<p>Hopefully this doesn&#8217;t go on for too long, the conversion.</p>



<p>decimal number is just that. How do we convert? If you watch my other videos, it&#8217;s basically the</p>



<p>same thing as converting from decimal to binary, except instead of dividing by two, because binary</p>



<p>is base two, we&#8217;ll divide by 16 because hex is base 16. So I&#8217;m going to start off by saying,</p>



<p>let&#8217;s take the original number and we&#8217;ll divide it by not two, 16. What does that equal? There&#8217;s</p>



<p>no way I&#8217;m doing this in my head. So I&#8217;m just going to use a calculator for every single step,</p>



<p>going to use a calculator for every single step not even going to try I&#8217;m</p>



<p>going to say this number divided by 16 is 5 1 1 7 5 7 with some sort of a</p>



<p>remainder so I&#8217;m gonna go 5 1 1 7 5 7 remainder something so in most</p>



<p>calculators you can just punch up the modulo operator which is like the</p>



<p>percent symbol before I do that I just want to point out 0.75 is 3 4ths of</p>



<p>of whatever it is that is one you know that one character can represent we know</p>



<p>we can represent 16 different values what&#8217;s 16 divided by 4 that&#8217;s 4 so three</p>



<p>of those should be like 12 I hope unless I&#8217;m saying something totally wrong so</p>



<p>I&#8217;m gonna do modulo so that&#8217;s 12 okay remainder 12 my dog is growling at me</p>



<p>He likes to lie about peeing.</p>



<p>He doesn&#8217;t actually pee.</p>



<p>He already did a huge pee and then three times after that at 20 minute intervals, he went</p>



<p>out there and lifted his leg and just like three squirts came out and he expected a giant</p>



<p>treat for it.</p>



<p>I&#8217;m not doing it.</p>



<p>You&#8217;re not getting that treat.</p>



<p>I expect a big pee pee if you want a treat.</p>



<p>You dog?</p>



<p>Dang little dog.</p>



<p>Okay.</p>



<p>So, here we are still dividing.</p>



<p>here we are still dividing. I got the remainder. So then we just need to take, you know, the</p>



<p>quotient result, you know, what is the result of actually dividing, just carry it over to</p>



<p>the next line. I&#8217;m going to do some spaces to make it look all even and continue to divide.</p>



<p>So divided by 16 equals something. Don&#8217;t forget that if you have the modulo operator over there,</p>



<p>you got to take it out, go back to division. It&#8217;s going to be 31984 remainder something.</p>



<p>what&#8217;s the remainder i&#8217;m just going to get the modulo i don&#8217;t want i don&#8217;t want to recall what</p>



<p>0.8125 is i&#8217;m sure some of you out there can already do that but it is 13 remainder 13.</p>



<p>um so i&#8217;m gonna go 319 divided by 16 31984 divided by 16 so it&#8217;s going to be 1 999 okay so carry that</p>



<p>over real fast though divided by 16 equals 1 9 9 remainder something there&#8217;s no decimal point at the</p>



<p>There&#8217;s no decimal point at the end of that so I can just assume the remainder is going to be zero.</p>



<p>If you want to double check to be sure, which is a good idea, use the modulo operator.</p>



<p>If your calculator doesn&#8217;t have modulo, find another calculator or jump into Python or something.</p>



<p>So I&#8217;m going to carry over 199 to the next line there.</p>



<p>1, 2, 4, remainder, whatever modulo says, 15.</p>



<p>That&#8217;s pretty cool.</p>



<p>All right, then I&#8217;m gonna carry it over,</p>



<p>just 1, 2, 4, divided by 16 again.</p>



<p>If you were hoping I&#8217;d be able to do it in my head by now,</p>



<p>you were wrong.</p>



<p>1, 2, 4, divided by 16, it&#8217;s gonna be 7.75,</p>



<p>so just like seven, remainder something.</p>



<p>What did I say last time for the 3 4ths?</p>



<p>Was that 12?</p>



<p>whoops, I can&#8217;t remember anymore.</p>



<p>12, yeah, okay, so remainder 12.</p>



<p>And then we&#8217;ll carry it over and we&#8217;ll say 7 divided by 16.</p>



<p>So we know that, you know, 16 doesn&#8217;t really fit into 7 at all.</p>



<p>So it&#8217;s going to be 0 remainder, whatever the number is.</p>



<p>Let&#8217;s punch it here just to double check.</p>



<p>We&#8217;ll say 7 divided by 16.</p>



<p>You can see that it&#8217;s 0.</p>



<p>And then the remainder is going to be 7, just, you know, what the original number was.</p>



<p>number was. So now at this point when the actual you know carry down quotient is</p>



<p>going to be zero then we just have zero divided by 16 equals just zero remainder</p>



<p>zero and it&#8217;ll just continue like this forever and ever and ever and ever and</p>



<p>ever. So this is how you know you&#8217;re done. Another thing that I mentioned in</p>



<p>other videos is how do we actually know where the zeros belong? I mean if you</p>



<p>read this intuitively from the top to the bottom you might think that you know</p>



<p>you know the top number is going to be like the first digit but it&#8217;s actually</p>



<p>backwards it goes from the bottom up the reason you can know that is again based</p>



<p>on my other videos if we just type a random decimal number here if I add</p>



<p>zeros to the right side I&#8217;m actually changing the value of the number I&#8217;m</p>



<p>making it bigger but if I add zeros to the left side I&#8217;m not changing the value</p>



<p>at all so that means those zeros here which could go on for infinity based on</p>



<p>how much tenacity you have they should be on the left side because you don&#8217;t</p>



<p>side because you don&#8217;t want any amount of these zeros to change the value of your number because</p>



<p>they you know it&#8217;s an arbitrary number of zeros based on how how fast you get tired of doing zeros</p>



<p>so that means if i go from top to bottom i have to reverse it if i go from bottom to top it&#8217;s</p>



<p>already going to be in the right order or sorry if i if i correlate or if i map bottom to top to mean</p>



<p>left to right then it&#8217;s fine already if i map top to bottom for left to right then i&#8217;ll have to</p>



<p>For left to right, then I&#8217;ll have to reverse it when I&#8217;m done.</p>



<p>So I&#8217;ll do it both ways just to show you.</p>



<p>But there&#8217;s one more step we need to do because in hexadecimal,</p>



<p>we have more characters than decimal.</p>



<p>We have to translate what does this 12 and 13 and these other numbers mean.</p>



<p>Luckily, we had some of them in there.</p>



<p>It could have been too easy.</p>



<p>So remember in hex, we have 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.</p>



<p>And then we have A, B, C, D, E, right?</p>



<p>So we know that the value of 0 is 0 and 1 is 1 and 2 and 2 and so forth, right?</p>



<p>Like 9 is 9.</p>



<p>But what&#8217;s the value of A?</p>



<p>For each increasing digit, the value just goes up by 1.</p>



<p>So that means that A is worth 10.</p>



<p>I&#8217;m going to write this vertically just so that you understand that this means the strength</p>



<p>of the A is 10.</p>



<p>And then the strength of the B is going to be 11 because it just increases by 1.</p>



<p>The strength of the C is 12.</p>



<p>The strength of the D is 13.</p>



<p>Oops, I forgot the F.</p>



<p>Oops, I forgot the F. Hit F in the chat if you forgot the F too.</p>



<p>So the strength of the E is 14. The strength of the F is 15.</p>



<p>And then we&#8217;re done. And remember, there&#8217;s 16 digits total.</p>



<p>So the highest value is 15 because it includes the zero.</p>



<p>So, you know, 16 total possible values you could represent, but the highest value, 15.</p>



<p>So that means every time we see a 12 here,</p>



<p>say that that&#8217;s really a C and every time we see actually let me let me put</p>



<p>the other C in there real fast every time we see a 13 that means it&#8217;s a D</p>



<p>every time we see a zero zero through nine it just it means the original</p>



<p>number oh wow we only had two digits that are gonna mean the original number</p>



<p>so mark my words you know the 15 is gonna be an F every time you see zero</p>



<p>one two three four five six seven eight nine it maps to the same number so seven</p>



<p>maps to seven it&#8217;s totally fine the only time it maps to a letter is of course when you exceed nine</p>



<p>so 10 and above are going to map to letters so now i have these mappings i just need to sort of scan</p>



<p>uh my my work to come up with the correct hexadecimal number so i&#8217;ll start from top to</p>



<p>bottom because it&#8217;s a little bit harder that way and it&#8217;ll be more brain practice i&#8217;m going to go</p>



<p>and then you know as many zeros as you decided to calculate and hopefully this</p>



<p>reminds you oh no I&#8217;m increasing the value by adding the zeros that means I</p>



<p>have to reverse everything so I&#8217;m gonna get rid of these zeros though and I&#8217;m</p>



<p>gonna reverse it 7cf0dc okay great now let&#8217;s double check because it&#8217;s always</p>



<p>a great idea to check your work in different ways with different methods to</p>



<p>decrease the possibility that you&#8217;re accidentally wrong so now I&#8217;m gonna go</p>



<p>So now I&#8217;m going to go from bottom to top and see if it&#8217;s the same thing.</p>



<p>7 C F 0 D C. Does it match? Yes.</p>



<p>So now I&#8217;m pretty confident that I have the right answer.</p>



<p>Let me punch this up in my personal calculator real fast.</p>



<p>I&#8217;m going to do just to double check the work before we cut the camera,</p>



<p>because if I&#8217;m wrong, I want to be able to correct myself right away.</p>



<p>Instead of coming back with another video later,</p>



<p>which sometimes I guess I&#8217;ll have to do.</p>



<p>f0 dc is the correct answer all right so we now have converted our first number from decimal to</p>



<p>hexadecimal nice and by the way if you didn&#8217;t already know this you&#8217;re supposed to put a</p>



<p>prefix in front of hexadecimal numbers not necessarily in every program that asks for</p>



<p>hex input some of them are not programmed that way but in general when you expect someone to</p>



<p>read your numbers if it&#8217;s hex you want to put ox in front of it because you don&#8217;t want them to</p>



<p>confuse, let&#8217;s say we have this number and this number and this number. All three of those could</p>



<p>be a different number depending on whether they&#8217;re binary or decimal or hex. But if you put the</p>



<p>symbols in front, this is binary, this is hex, then now the reader knows that these are three</p>



<p>different numbers and they can infer what the numbers mean. Okay, so let me, let&#8217;s just do like</p>



<p>another number. We&#8217;ll make it a little bit smaller so it&#8217;s easier. We&#8217;ll say decimal and we&#8217;ll go two,</p>



<p>and we&#8217;ll go 2 2 3.</p>



<p>So it&#8217;s faster.</p>



<p>So we start off with 2 2 3,</p>



<p>we divide it by 16,</p>



<p>and that&#8217;s going to be something.</p>



<p>So 2 2 3 divided by 16</p>



<p>is going to be 13 remainder something.</p>



<p>I&#8217;m going to do the modulo operator.</p>



<p>And by the way,</p>



<p>if you don&#8217;t have a modulo operator</p>



<p>and you can&#8217;t figure out a better way to do this,</p>



<p>a good trick is to just say,</p>



<p>let&#8217;s take 13,</p>



<p>because that was the answer, right?</p>



<p>13 point something.</p>



<p>We&#8217;ll take 13 and multiply that by 16 again,</p>



<p>that by 16 again so it goes higher then take the difference between that and the original number</p>



<p>so we can say 223 minus uh the number multiplied back up and it&#8217;ll tell us that our remainder is 15.</p>



<p>let&#8217;s see was that actually the remainder let me just double check here oh gosh what am i doing</p>



<p>223 modulo 16 15 yeah there it is if you&#8217;re lazy like me you could also do something like this i</p>



<p>and I don&#8217;t have a modulo.</p>



<p>I&#8217;ll do 13 times 16 and it&#8217;s 208.</p>



<p>And then I&#8217;ll just subtract the original number</p>



<p>and then we get negative 15,</p>



<p>but then I know it&#8217;s not negative, I know it&#8217;s 15.</p>



<p>So it&#8217;s just like, it makes you a little bit faster</p>



<p>in the calculator.</p>



<p>So this number I think was too small</p>



<p>because we just do 13 and then divide that by 16.</p>



<p>Obviously the answer is gonna be zero remainder 13.</p>



<p>And we just have a two digit hexadecimal number.</p>



<p>digit hexadecimal number. Let&#8217;s do that real fast. What is 15 going to be? It&#8217;s A and no, no,</p>



<p>no, not A. Sorry. That&#8217;s F. Subtract two from that. D E F. So it&#8217;s going to be D, I think.</p>



<p>So then if we go from bottom to top, it&#8217;s going to be O X D F. Let me double check that I&#8217;m</p>



<p>telling you the right thing. 223 D F. Okay. So we got it right. Let&#8217;s do something just like a</p>



<p>not as difficult as the first one so I&#8217;ll try four digits maybe two two two two</p>



<p>how about that four digital four digital digits how about that we&#8217;ll do</p>



<p>two eight one six divided by 13 equals something two eight one six divided by</p>



<p>16 that&#8217;s 176 remainder something there&#8217;s no decimal point so I can just</p>



<p>16 is 176 divided by 16 is 11.</p>



<p>Another zero remainder.</p>



<p>Getting kind of boring though, isn&#8217;t it?</p>



<p>Remainder zero.</p>



<p>And then we&#8217;ll do 11 divided by 16.</p>



<p>That&#8217;s going to be zero remainder 11.</p>



<p>That&#8217;s too easy.</p>



<p>Okay.</p>



<p>So what is zero?</p>



<p>Zero is zero.</p>



<p>You&#8217;re welcome.</p>



<p>And then what is zero?</p>



<p>It&#8217;s also zero.</p>



<p>0, it&#8217;s also 0 and then what is 11? That&#8217;s B.</p>



<p>So we should have a number now of 0xB00 if we&#8217;re going from the bottom to the top.</p>



<p>If you go from the top to the bottom of course it&#8217;ll be 00B and then you reverse it B00</p>



<p>but I just wanted to skip that step for now.</p>



<p>Let me punch this up into my personal calculator to make sure I don&#8217;t need to make a correction.</p>



<p>B00, there we go.</p>



<p>Also, you know, here&#8217;s another thing to keep in mind.</p>



<p>it&#8217;s to read you know sets of bytes which typically go in patterns of one byte or two</p>



<p>bytes or four bytes or eight bytes or whatever so the cool thing about hex is one character</p>



<p>can represent a number from zero uh to 15 or 16 combinations and if you think about that in binary</p>



<p>that&#8217;s four bits right it&#8217;s like one two three four one two four eight multiply eight by two</p>



<p>16 subtract 1 is 15.</p>



<p>So you can go from 0 to 15.</p>



<p>So that means for every character in hex,</p>



<p>you get four characters of binary.</p>



<p>So it&#8217;s like a huge savings, right?</p>



<p>But the point is, if you wanted to represent one byte,</p>



<p>that&#8217;s not going to be four bits.</p>



<p>That&#8217;s going to be, you know,</p>



<p>four bits followed by four bits for a total of eight bits.</p>



<p>Even if there are zeros in the beginning,</p>



<p>in binary, if you&#8217;re representing a byte,</p>



<p>But in binary, if you&#8217;re representing a byte, you typically want to pad the zeros to the</p>



<p>left so that it looks like it&#8217;s aligned to nice blocks of eight or 16 or 32 or 64 in</p>



<p>terms of bits.</p>



<p>So we should do the same thing with hex.</p>



<p>We should always have two hex digits together.</p>



<p>We should try not to have like an odd number of hex digits.</p>



<p>And if you want to get more strict than that and say like, oh, only, you know, two or four</p>



<p>eight you can do that but i just will say pad it with a zero to the left remember when you pad a</p>



<p>number with zeros to the left it doesn&#8217;t change the value like if i just put a bunch of zeros in</p>



<p>front of this decimal number it wouldn&#8217;t change the value so we can do that with hex and it looks</p>



<p>nicer and neater and people can quickly see okay so there&#8217;s like a byte right there it&#8217;s ob</p>



<p>they can imagine oh that byte is probably um 11. so there&#8217;s like a like an 11 byte it&#8217;s like got</p>



<p>a sequence of zeros and ones and then there&#8217;s another byte right after it which is smaller</p>



<p>which is smaller, which just has zeros.</p>



<p>So it just helps the reader visualize what&#8217;s going on.</p>



<p>Okay, I&#8217;m going to cut the video here.</p>



<p>I hope you enjoyed this video.</p>



<p>I hope you learned a little bit of stuff and had a little bit of fun.</p>



<p>I&#8217;ll see you in the next video.</p>



<p>Hey, everybody.</p>



<p>Thanks for watching this video again from the bottom of my heart.</p>



<p>I really appreciate it.</p>



<p>I do hope you did learn something and have some fun.</p>



<p>If you could do me a please, a small little favor,</p>



<p>please a small little favor could you please subscribe and follow this channel</p>



<p>or these videos or whatever it is you do on the current social media website</p>



<p>that you&#8217;re looking at right now it would really mean the world to me and</p>



<p>it&#8217;ll help make more videos and grow this community so we&#8217;ll be able to do</p>



<p>more videos longer videos better videos or just I&#8217;ll be able to keep making</p>



<p>videos in general so please do do me a kindness and and subscribe you know</p>



<p>sometimes I&#8217;m sleeping in the middle of the night and I just wake up because I</p>



<p>And I just wake up because I know somebody subscribed or followed.</p>



<p>It just wakes me up and I get filled with joy.</p>



<p>That&#8217;s exactly what happens every single time.</p>



<p>So you could do it as a nice favor to me or you could troll me if you want to just wake me up in the middle of the night.</p>



<p>Just subscribe and then I&#8217;ll just wake up.</p>



<p>I promise that&#8217;s what will happen.</p>



<p>Also, if you look at the middle of the screen right now, you should see a QR code,</p>



<p>which you can scan in order to go to the website, which I think is also named somewhere at the bottom of this video.</p>



<p>where you can just kind of like see all the videos I published and the services</p>



<p>and tutorials and things that I offer and all that good stuff and if you have</p>



<p>a suggestion for clarifications or errata or just future videos that you</p>



<p>want to see please leave a comment or if you just want to say hey what&#8217;s up</p>



<p>what&#8217;s going on you know just send me a comment whatever I also wake up for</p>



<p>those in the middle of the night I get I wake up in a cold sweat I&#8217;m like this</p>



<p>really it really mean the world to me I would really appreciate it so again thank you so much</p>



<p>for watching this video and enjoy the cool music as as I fade into the darkness which is coming for</p>



<p>us all</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/how-to-convert-decimal-to-hexadecimal-fun-easy-guide-for-beginners/">How to Convert Decimal to Hexadecimal: Fun &amp; Easy Guide for Beginners</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/how-to-convert-decimal-to-hexadecimal-fun-easy-guide-for-beginners/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Master Number Bases: Decimal, Binary, and Hexadecimal Explained!</title>
		<link>https://www.NeuralLantern.com/master-number-bases-decimal-binary-and-hexadecimal-explained/</link>
					<comments>https://www.NeuralLantern.com/master-number-bases-decimal-binary-and-hexadecimal-explained/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Thu, 03 Apr 2025 13:34:59 +0000</pubDate>
				<category><![CDATA[Videos]]></category>
		<category><![CDATA[0b prefix]]></category>
		<category><![CDATA[0x prefix]]></category>
		<category><![CDATA[base 10]]></category>
		<category><![CDATA[base 16]]></category>
		<category><![CDATA[base 2]]></category>
		<category><![CDATA[binary explained]]></category>
		<category><![CDATA[binary numbers]]></category>
		<category><![CDATA[coding for beginners]]></category>
		<category><![CDATA[computer science basics]]></category>
		<category><![CDATA[decimal to binary]]></category>
		<category><![CDATA[geeky tutorials]]></category>
		<category><![CDATA[hex vs binary]]></category>
		<category><![CDATA[hexadecimal numbers]]></category>
		<category><![CDATA[hexadecimal tutorial]]></category>
		<category><![CDATA[how computers work]]></category>
		<category><![CDATA[learn binary]]></category>
		<category><![CDATA[number bases]]></category>
		<category><![CDATA[number systems]]></category>
		<category><![CDATA[programming tips]]></category>
		<category><![CDATA[tech education]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=43</guid>

					<description><![CDATA[<p>Hello there! Ever wondered what number bases are all about? In this video, we?re diving into decimal (base 10 &#8211; the one you already know), binary (base 2 &#8211; just&#8230;</p>
<p>The post <a href="https://www.NeuralLantern.com/master-number-bases-decimal-binary-and-hexadecimal-explained/">Master Number Bases: Decimal, Binary, and Hexadecimal Explained!</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-wp-embed is-provider-rumble-com wp-block-embed-rumble-com"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" title="Master Number Bases: Decimal, Binary, and Hexadecimal Explained!" src="https://rumble.com/embed/v6pe6ux/#?secret=olHl5zk87A" data-secret="olHl5zk87A" width="1000" height="563" frameborder="0"></iframe>
</div></figure>



<p>Hello there! Ever wondered what number bases are all about? In this video, we?re diving into decimal (base 10 &#8211; the one you already know), binary (base 2 &#8211; just 1s and 0s, how your computer thinks), and hexadecimal (base 16 &#8211; the compact cool kid). I?ll show you how the same number looks totally different across these systems &#8211; binary gets LONG, hex keeps it short and sweet. Plus, why do we even use hex? Spoiler: it?s a game-changer for reading computer memory. Stick around to learn handy prefixes like 0x and 0b to avoid mix-ups. Want to be as cool as those binary-converting pros? Hit subscribe, scan the QR code for more, and let?s geek out together in the next video &#8211; conversions are coming up! Drop a comment with your thoughts or just say hi &#8211; it might wake me up in the middle of the night with joy! </p>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hello there. Let&#8217;s talk about number bases. So what are number bases? You&#8217;ve probably at some</p>



<p>point heard someone say, hey, I can convert between decimal and binary or between decimal</p>



<p>and hexadecimal or hexadecimal and binary. And you thought that that person was way cooler than you</p>



<p>were. Well, they are way cooler than you. But if you watch my videos, maybe you can be just as cool</p>



<p>Anyway, so what do we mean by number basis exactly?</p>



<p>We&#8217;ll start with decimal,</p>



<p>which is the number system that everybody already understands, I hope.</p>



<p>So in decimal, you have 10 characters, right?</p>



<p>So we&#8217;ll say like 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.</p>



<p>It&#8217;s like 9, or sorry, 10 possible characters.</p>



<p>So decimal is actually base 10.</p>



<p>I&#8217;m going to write base 10 here.</p>



<p>Decimal is base 10.</p>



<p>base 10 because it has 10 available characters. The next thing is binary. You&#8217;ve probably heard</p>



<p>of that before. Even a lot of non-computer scientists understand binary at least a little</p>



<p>bit because it&#8217;s just ones and zeros, right? This is how your computer represents information.</p>



<p>All characters, all numbers, all floats, all everything. They really just come down to zeros</p>



<p>and ones inside of the computer. And it&#8217;s not like there&#8217;s an actual zero or an actual one anywhere.</p>



<p>It&#8217;s more like there&#8217;s a certain voltage that represents a one or there&#8217;s a different voltage</p>



<p>represents a 1 or there&#8217;s a different voltage that represents a 0.</p>



<p>You can think of it as just like voltage or no voltage, but that&#8217;s not always the case.</p>



<p>But you know, long story short, it&#8217;s just 1s and 0s.</p>



<p>So in binary, we can just represent a 0 or we can represent a 1 and that&#8217;s it.</p>



<p>Because there&#8217;s only two characters that we can use to represent numbers, we call this</p>



<p>base 2.</p>



<p>So that&#8217;s binary.</p>



<p>Now not a lot of people have heard of hexadecimal outside of computer science, but hexadecimal</p>



<p>outside of computer science but hexadecimal is a number is another</p>



<p>number system that we can use which uses base 16 the reason we use hexadecimal is</p>



<p>it because it kind of it kind of compacts a number I&#8217;ll show you in a</p>



<p>second how it can represent the same number but with less characters you can</p>



<p>imagine in binary if we have base 2 there&#8217;s only two characters that means</p>



<p>the same number in decimal versus binary it&#8217;s probably going to be a lot longer</p>



<p>imagine that, right?</p>



<p>Because it&#8217;s not like the actual numbers change</p>



<p>that we&#8217;re trying to represent.</p>



<p>It&#8217;s just that the representation changes.</p>



<p>So hex or hexadecimal,</p>



<p>we have 16 different characters.</p>



<p>Did I say 15 a moment ago?</p>



<p>Sorry if I did.</p>



<p>So we start with the normal ones that base 10 has,</p>



<p>decimal has.</p>



<p>So we go three, four, five, six, seven, eight, nine.</p>



<p>So that&#8217;s 10.</p>



<p>the extra five, we do A, B, C, D, E, F. Sorry, extra six. I knew I was going to say five at some</p>



<p>point. So in hexadecimal, we have the characters zero, one, two, three, four, five, six, seven,</p>



<p>eight, nine, and then A, B, C, D, E, F. For a total of 16 characters, or one digit can represent</p>



<p>here. So this is the basics of the differences between the number systems. Let me show you a</p>



<p>quick example. Let me see if I got my calculator here. Hopefully it&#8217;ll work. Okay. I&#8217;m going to do,</p>



<p>let&#8217;s see, variables. So how do you get into this one? Mode. Oh, number base. So I&#8217;m going to do,</p>



<p>let&#8217;s just pick a random number in decimal. So I&#8217;m going to say like, you know, just hit the</p>



<p>So you can see that if I type a number in decimal and show it in decimal, then well,</p>



<p>it&#8217;s the exact same size as you probably have suspected.</p>



<p>But if I represent this exact same number in binary, you should probably expect that</p>



<p>the representation is going to be way longer because again, binary only has two characters</p>



<p>to work with.</p>



<p>So it&#8217;s harder for it to represent the same information.</p>



<p>So I&#8217;m going to change the expression base here to binary.</p>



<p>Oh no, what&#8217;s happening?</p>



<p>What&#8217;s going on here?</p>



<p>Expression base.</p>



<p>Oh, I did the wrong thing.</p>



<p>Decimal is the expression base.</p>



<p>Binary is the result base.</p>



<p>Okay.</p>



<p>So that same number that we had before, 871, 876, 42,</p>



<p>look at how huge it is in binary.</p>



<p>Takes up a lot of your screen, right?</p>



<p>So we use binary because it&#8217;s the closest representation</p>



<p>to what the actual machine has.</p>



<p>So that&#8217;s good.</p>



<p>Especially if you want to start manipulating individual bits</p>



<p>manipulating individual bits for one reason or another. It&#8217;s good to know how to, it&#8217;s good to</p>



<p>understand binary. But hexadecimal is useful, like I said before, to compact the same number. So</p>



<p>again, because the base of the original number is 10, you know, we had the original number in decimal.</p>



<p>If we show a hexadecimal version of it, it should be shorter because there&#8217;s 16 characters to work</p>



<p>with. It&#8217;s easier for it to represent the same information. So the result base, I&#8217;m just going</p>



<p>hexadecimal here and look at how short that number is the original number is one two three four five</p>



<p>six seven eight it&#8217;s eight characters long but the hexadecimal number is two four six seven</p>



<p>characters long and that savings in characters will go up and up and up the more you know the</p>



<p>longer the original or the bigger the original number is let me see if I can just add some more</p>



<p>numbers here okay let&#8217;s see if we get more savings here one two three four five six seven eight nine</p>



<p>Okay, so the original number is 15 long and here we have 2, 4, 6, 8, 10, 12, 13.</p>



<p>So that&#8217;s a savings.</p>



<p>Now think about it this way.</p>



<p>This is a huge savings compared to binary.</p>



<p>Let&#8217;s go back to binary real fast.</p>



<p>Same number, which is currently in hex.</p>



<p>As soon as I start showing it in binary, the number explodes.</p>



<p>So there are a lot of numbers, especially if you have a 64-bit number, which you work</p>



<p>if you were to just take you know one of those 64-bit numbers and try to express it in binary</p>



<p>it&#8217;s just kind of like it&#8217;s really really long and if you want to represent anything even a little</p>



<p>bit bigger like 128-bit numbers or even the contents of memory from you know one memory</p>



<p>location to another binaries just can explode and fly off the screen so this is why I mean this is</p>



<p>one of the biggest reasons why we use hexadecimal because it&#8217;s just it&#8217;s easier to see what&#8217;s inside</p>



<p>of the computer it&#8217;s easier than decimal and it&#8217;s easier than binary at least once you understand</p>



<p>hexadecimal one other thing that i want to uh show you real fast let me see like let me change</p>



<p>that back to decimal so i don&#8217;t screw myself later okay um suppose that you wanted to represent a</p>



<p>number in binary sorry let&#8217;s say decimal well you know we&#8217;ll say like one two three four right and</p>



<p>well actually let&#8217;s not do one two three four let&#8217;s say like a thousand and one and then you</p>



<p>want to represent a number in binary and you write one zero zero one and then you want to</p>



<p>represent a number in hexadecimal you could also have one zero zero one right the problem is that</p>



<p>each of these numbers are actually different numbers they only look the same because the</p>



<p>character representation is the same but not the actual number so how do you uh how do you sort of</p>



<p>How do you sort of like differentiate and make sure that the person reading the numbers that you&#8217;ve written down knows what base they&#8217;re in?</p>



<p>Because if you know if you&#8217;re a computer scientist or you&#8217;re doing some kind of crazy math, then</p>



<p>well, it might not be obvious and</p>



<p>you want to be careful that the person doesn&#8217;t misinterpret your results.</p>



<p>Okay, so let me do that thing again real fast</p>



<p>just to prove to you. What am I doing here? Units? No.</p>



<p>Mode.</p>



<p>Okay, so I&#8217;m going to say if I write 1001, I&#8217;m going to display it as decimal,</p>



<p>but the input is first going to be decimal.</p>



<p>So in decimal, 1001 is 1001.</p>



<p>Okay, that&#8217;s fine.</p>



<p>But if this 1001 was actually a binary number,</p>



<p>I&#8217;m going to say that the expression base is binary here.</p>



<p>Notice how the real number is actually 9 if you represented it in decimal.</p>



<p>expression like the original number was you know the characters were hexadecimal then the real</p>



<p>decimal version of 1001 would be 4097 that&#8217;s three totally different numbers so you got to be careful</p>



<p>that you know what you&#8217;re reading and you got to be careful that you help the person reading what</p>



<p>you&#8217;re writing down if you&#8217;re trying to transmit this information so with hexadecimal a really</p>



<p>really common prefix that everyone should use is ox ox and then any number after that usually just</p>



<p>reading this is a hexadecimal number so there&#8217;s no ambiguity same thing for binary you&#8217;ll just say</p>



<p>like ob and then for decimal you just just leave it alone i think there&#8217;s a another prefix you can</p>



<p>use but i usually don&#8217;t use anything but at least uh ob says this is binary and ox means this is</p>



<p>hexadecimal and then nothing just means okay just default to human reading just decimal</p>



<p>okay this was the basics of number bases in other videos i&#8217;m going to talk about how to actually</p>



<p>between these three bases maybe in the future at some other point in some other</p>



<p>video far off in YouTube land I might talk about octal or some other base but</p>



<p>in the immediate future it&#8217;s going to be decimal binary and hexadecimal so I</p>



<p>hope you&#8217;ve enjoyed this video I&#8217;ll see you in the next</p>



<p>hey everybody thanks for watching this video again from the bottom of my heart</p>



<p>I really appreciate it I do hope you did learn something and have some fun if you</p>



<p>a small little favor could you please subscribe and follow this channel or</p>



<p>these videos or whatever it is you do on the current social media website that</p>



<p>you&#8217;re looking at right now it would really mean the world to me and it&#8217;ll</p>



<p>help make more videos and grow this community so we&#8217;ll be able to do more</p>



<p>videos longer videos better videos or just I&#8217;ll be able to keep making videos</p>



<p>in general so please do do me a kindness and and subscribe you know sometimes</p>



<p>I&#8217;m sleeping in the middle of the night and I just wake up because I know</p>



<p>wake up because I know somebody subscribed or followed. It just wakes me up and I get filled</p>



<p>with joy. That&#8217;s exactly what happens every single time. So you could do it as a nice favor to me or</p>



<p>you could you could troll me if you want to just wake me up in the middle of the night just</p>



<p>subscribe and then I&#8217;ll just wake up. I promise that&#8217;s what will happen. Also if you look at the</p>



<p>middle of the screen right now you should see a QR code which you can scan in order to go to the</p>



<p>website which I think is also named somewhere at the bottom of this video and it&#8217;ll take you to my</p>



<p>You can just kind of like see all the videos I published and the services and tutorials and things that I offer and all that good stuff.</p>



<p>And if you have a suggestion for clarifications or errata or just future videos that you want to see, please leave a comment.</p>



<p>Or if you just want to say, hey, what&#8217;s up? What&#8217;s going on? You know, just send me a comment, whatever.</p>



<p>I also wake up for those in the middle of the night. I wake up in a cold sweat and I&#8217;m like,</p>



<p>It would really mean the world to me.</p>



<p>I would really appreciate it.</p>



<p>So again, thank you so much for watching this video.</p>



<p>And enjoy the cool music as I fade into the darkness, which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/master-number-bases-decimal-binary-and-hexadecimal-explained/">Master Number Bases: Decimal, Binary, and Hexadecimal Explained!</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/master-number-bases-decimal-binary-and-hexadecimal-explained/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
