108: Data Types: Ints Part 1.

Take Up Code - Un pódcast de Take Up Code: build your own computer games, apps, and robotics with podcasts and live classes

Categorías:

You’ll probably have one or more ints in almost every method and class you write. They’re everywhere so you really should know how to use them. This episode explains the data lengths of various ints and pointers along with words. Do you know what a word is? How about a double word or a DWORD? A quad word or a QWORD? A double quad word or a DQWORD? Do you understand how these relate to processors and operating systems? And how about the short, int, long, and long long types? Do you understand some of the problems that can be caused by pointers switching from 32 bits to 64 bits? This episode describes all this plus five systems for describing the lengths of all these types: LP32 – The long and pointer types are 32 bit. This means that shorts and ints are 16 bit. ILP32 – The int, long, and pointer types are 32 bit. This means that shorts are 16 bit. LLP64 – The long long and pointer types are 64 bit. This means that ints 32 bit. And shorts are still 16 bit. LP64 – The long and pointer types are 64 bit. This means that long longs are also 64 bit. Ints are 32 bit. And shorts are still 16 bit. ILP64 – This is not a very common system. The int, long, and pointer types are 64 bit. This means that long longs are also 64 bit. And I’m not sure what length shorts are. Listen to the full episode or you can also read the full transcript below. Transcript Int is short for integer and that means they can hold whole numbers including zero. And just like the chars and bytes from the previous episode, an int can hold negative numbers if it’s signed. There’s a lot of history around ints and knowing this can help you better understand all the differences surrounding ints. There’s a lot more variations of ints than there are chars and bytes. Let’s start out then with the word. The way I always understood word was that it matched the basic width of the processor and while this definition might still be valid for the processors themselves, a lot of prior software assumes that a word is 16 bits. You can find 32 systems today that define a word to be 32 bits and you can also find 64 bit systems that define a word to be 64 bits. While I like this system because it gives a nice name to the width of data that the processor can handle natively, I have to say that I’ve personally had a lot more experience on systems where the word got stuck at 16 bits. So if a word is stuck at 16 bits, then what do we call a 32 bit value on a 32 bit system? It’s called a double word or a dword for short. You probably want to avoid calling it a double word because a double is another data type that I’ll explain in an upcoming episode. Calling it a dword avoids this confusion. And what is a 64 bit value called on a 64 bit system when the word is still defined to be 16 bits? That’s a quad word. Or a qword for short. And what will we call a 128 bit value when 128 bit processors become more common? If we follow the same pattern, then it’ll probably be a double quad word or a dqword for short. It would have probably been much better if the simple term word had advanced in software like it did on the hardware side in modern computers. Because of this, even the term word must be questioned and defined to make sure everybody agrees what they’re talking about. You normally don’t have a builtin datatype in languages called a word though. I explained it because it is used in programming as a definition for some other type. You may actually see a DWORD usually spelled in all uppercase letters when programming and now you’ll know some history behind it and can know to check exactly what type it really means. Usually, it’ll be 32 bits. What most languages do support is the int. But we can’t just stop with a simple int. Not when we have all this confusion around words. So to even things out a bit, there’s short ints sometimes just called a short, ther

Visit the podcast's native language site