What Is Signed & Unsigned Entities? C Programming. » My Blogging

# What is signed & unsigned entities? C Programming.

Now, since we have an unsigned entity, we pretty much know that this is not a sign for the unsigned entity. So MSB represents a value. So now our hypothesis or assumption is correct. Two to the power 32. Okay, that’s bad. Now let’s break it further. What was our assignment? Hardest partition size 10 gig. So let’s see. What is the maximum value of this particular number? For the sake of calculation, I will just assume it to be two to the Power 32, will ignore minus one for the sake of calculation. Okay, so let’s come back here into the calculation.

What’s Two to the Power 32? Right. That’s where I’m at, two to the Power 32 equals two to the Power two * 2 to the Power 30 and two to the Power 30, as you know, can be broken down. So this can be broken down further. So two to the Power two and to the Power 30. So this is 4. 2 to the power 2. It is four * Two to the Power 10 * two to the power 10, and then totally 2 to the power 10, three times. Right. So when you see these three times, so this is two to the Power 10, some of the readers who are more advanced, understand two to the Power 10 is exactly 1-0-2-4. It is one kilobyte. This is 1 kilobyte. So what we are essentially ending into now. Right. We are now into a position where we can easily say that it is four-kilobyte kilobyte.

When we say it is four kilobytes x kilobytes x kilobytes, isn’t it? So what the answer? The answer when you see here is four kilos into kilo. Meg and this is a gig. So we are essentially looking at this number. Okay, so it’s a four gig. So the short answer or the long answer, eventually the long version. Right. So we have looked into now is the final answer. Four gigs. So this number is 4 GB. So what was our original assignment? Original assignment, as we wanted to have a data type where we can store this value. So this value was the 10 gig partition, and we have 4 GB here. So if you declare an integer, if you declare an unsigned integer here, then we will never be happy because an unsigned integer can store up to four gigs and then minus one. this is the value.

We cannot choose unsigned int. So unsigned int is not the correct answer. This is not correct. Not at all. Right. So this is not a correct answer. So what do we choose? So the choice there we have is basically now the last one. So we require one higher data type, as you know, basically. Okay. So you will have just to hold on. Yeah. So you will have the next choice that we are giving here. Right. Basically, it an unsigned. So we’ll have an unsigned long, unsigned long because long is the next higher data type after the integer. Right. So this is the correct answer. What is long? Long can contain long. 10 will contain eight bytes of data. Eight Bytes is a very large number. Two to the Power 64 minus one if it’s unsigned, actually.

This is the answer to the question of where you wanted to make sure that what’s the answer? I’m sure you understood the explanation. Right. So we have to have a careful focus on the choice of data type for our programming. Let’s move on to the next one now. Right. So which datatype is most suitable to store the data of an eight-bit microprocessor or a microcontroller? Right. So this is a very interesting question, because when we do embed programming when you interface in the kernel with the device drivers when you interface in the kernel with registers. Right. So anywhere you have an interaction with hardware, especially, we have to be very careful and choose the values. Right. Values for our data types or values mean the type for the variables. So we have to be very careful. If you don’t do that, then we’ll have a big problem.

The driver won’t work even though your code looks pretty fine, but the fundamentals are ignored, actually. Right. So what’s the answer to this choice? The answer was an unsigned character. Right. So in this example, we are seeing an unsigned char is the correct answer. So let’s look into again the same reasoning this time, I’m sure that you will really understand why or what it is, actually. So let’s look into it. All right. The scratchpad once again. So this is our assignment, too. So this was our test too, so when you look into this and we start calculating when you talk about eight bits. So it’s pretty simple now.

When you talk about eight-bit of data, so you have an eight-bit microprocessor, as you know, or an eight-bit microprocessor. Right. Generally with a microprocessor or the controller. Now you’re interfacing with your drivers, and then you wanted to communicate in their control registers. You get the data on the data register, you have a status. Right. So that’s more about low-level device driver programming. Okay. So quickly check when you think about the types. That’s the whole idea. Right. When you think about the types for this, just a second. Yeah. So when you think about the types, what we are really looking at is … it’s an eight-bit. So we have to ignore the other possibilities about integer.

Let’s look into the eight-bit, so we have a character versus an unsigned character. So when you have signed and unsigned characters, what do you choose? Again, people say I have a character, and they say they declare a register variable to interface with your say control register. Right. So you can have some register one, then you have some CTRL. Right. One. So you can have this kind of programming construct variable choices in your program. Right. Is the character a good thing is a question. Right. Once again, as you know that when you talk about the character data type, the memory requirement is one Byte and one Byte is, as you all know.

Now it has eight bits and eight bits really correspond to maximum possible or minimum possible values generally when we write it. Right. So remember, these are the eight-bit positions. Right. Basically. Now the question is, again, we have to take one as the least significant bit and this is the most significant bit, just a representation format. This is the least significant and most significant bit. Do you really want to know, do you really want to assign in your controller register one of the bits assigned bit? The reality is now because think about controller programming. Right. What do we do? We want to send some commands to that controller. And then suppose a controller is capable of accepting eight bits of input. Right. It means that it has two to the Power 8 = 256 functions. Okay. So the controller is a very powerful controller.