 What's up guys, my name is Michael and welcome to my YouTube channel. Today we are going to talk about Big Endian and Little Endian. So, um, what exactly is Big Endian and Little Endian? So basically, um, Big Endian and Little Endian are like different types of machines that, uh, that have the, like, depending on the type of machine, they store bits differently. Okay. So to determine what a Big Endian is, basically Big Endian is like the regular bits are stored first, like how you see normally, um, in a number. Um, Little Endian is when the far, the right most bits are actually stored first and then it's the far left bit. So Big Endian is the left most bits are stored first and Little Endian is right most bits and this matters if you're doing like stuff like networking where you actually, uh, if you code stuff like for networking where sometimes the bits and the bytes, uh, that, that the order where they get sent between different packets matter and they affect how the way the machines are working, right? So the way that you get them. So yeah, Big Endian and Little Endian depends on this type of processor and the machine that the computer has. So, um, basically, I'll just show you guys an example. Let's say I have, uh, the number one, two, three, four, five, six, seven, right? So basically, if you're going to store this in Big Endian, so this is going to be Big Endian, uh, so the bytes in memory are kind of like blocks of memory like this, right? So, um, if you're going to store every two bytes here, it would be like zero, one first, right? Because of the, the one right here, then we're going to do two, two, three, right? So, so zero, one, two, three, then we're going to do four, five, and then six, seven. Okay. And then the rest of this, the rest is just, uh, nothing there. So I'm, I'm actually going to erase the rest right here. So yeah, this would be what Big Endian is. Okay. And then the little endian is that the right most bits are actually stored first. So in little endian, it would be look like this. So this is little endian. Okay. So here, here's little endian. So instead of zero, one stored first, it's going to be six, seven, and it's going to be four, five, and it's going to be two, three, and it's going to be zero, one. Okay. So that's basically the difference between both of these. It's not much to it exactly. And then, yeah. And then, um, now we're actually just going to show you guys how to check if it's Big Endian or a little endian. All right, guys. So to tell if something is Big Endian or a little endian, as you can see here, um, Big Endian always starts with a zero in the first place right here, right? Because, um, we're going through every two bytes and, uh, there's always going to be a zero appended in the front because it does the, the, uh, left most bits first, right? Left most bits and bytes first. And it puts that in the memory first so that for Big Endian, it's always going to have a zero in the first place, right? For a little endian, it's always going to be a number in this first place, right? Because you're, you're always going to put the right most bits first. And then a little endian, there's always going to be a number here. So basically in order to check if, if it is a Big Endian or a little endian, you're just going to, all you have to do is put your number into like a small unsigned char, right? And then de-reference it. So then I'll give you the first number, right? And then if, if it's a zero, you know, it's a Big Endian. If it's, if it's not zero, you know, it's a little endian. Okay. And then I'll just show you guys a code cause that's, that's pretty much it. All right. So here's a code to basically do this for you. So we create a regular number integer and we, we call it i and we set equal to one. So this, this is just going to tell us if it's like, it could be any number actually, you could just, it could be any number you have. I just set it to one. I just set it the first value i equal to one, because one is like the most basic number you could possibly have. Then what I'm going to do is I'm going to make it into a character. So this is going to like forcibly put it into a character. And if you put it into a character, what it does is that it'll just get the first bit, right? Cause then all the other characters, uh, uh, basically a character is only, uh, has one bit, right? When one, one bit, right? So if you put it into a character, it's, it's going to get rid of all the other values on the right. So that's what it does, right? And this character pointer, right? So we set equal to basically cover into a character. And then we de-reference it. We, we basically get the, uh, reference pointer. So we create a character pointer and we point it to this number, which is one, right? And then we just de-reference it. We say, okay. So this de-referencing means that what we're pointing to. So here, but basically what this is doing is that this is going to create a pointer. This is going to be our pointer, right? It's going to point it to this, this number. And then it's going to de-reference it. So where it's going to get the data that it's pointing to at, which is going to be the first value in this case. So there will be one, right? And then, um, yeah, once it gets its one, if it's not equal to zero. So what this is, if statement is doing is checking if it's not equal to zero. So this is, this is the same thing as doing this, right? Uh, de-reference it. If it's not equal to zero, then we know it's little Indian, right? Because that means that the first value is not zero, right? A little Indian. That's what the little Indian is, right? Uh, if it's big Indian, then that means the first value is zero. And yeah, it's not equal. Then we just print out big Indian. So if I run this right now, it's basically just going to give me little Indian. Yeah. So my computer is little Indian. Okay. So that's basically how you do the, how to check big Indian or little Indian. Create a character point, a point to it, then de-reference it. And then, uh, if, if it's pretty much, if the first value of the bit is not equal to zero, you know, it's little Indian, otherwise it's big Indian, right? Based on what we said here. So yeah, rate, com, subscribe. I hope you guys enjoyed this video. I'll check you guys later. Peace.