Unsigned integer 16 bit so you have the range of 0 to 2^15
But what will make anyone declare a variable with such a huge capacity or are they just trying to follow good prog practices
Won't int serve close to the same purpose
It's capacity is 16 bits or 2 bytes
Int is 2^32 on older machines and 2^64 on modern systems
Okay...all I'm just confused is that some people declare variable with not definite/ absurd data type....looks at volatile int for example 🤧🤕
Yeah I'm cool on that thanks Avihay
Once upon a time, C had the keywords int, short and long. int was declared as an integer as the native word size of the architecture you are compiling to. And everyone lived in peace... Until you started putting code to different architectures, and was short int 8bit? Or 16bit? yes here and not there, and then everybody tried to kill everyone else because their size was right and the others were wrong! But tiered of the fighting, everyone started using type names with explicit bit count. And it was good enough, and in, I think, 1999, the 98 c standard peace treaty was signed, and there was peace
Volatile means that the value might change by some external factor ( like a different thread, or by some special register handling, and that the compiler shouldn't make assumptions about the value for optimization purposes
Ah yes well…
No int is different. The highest number in a signed integer is different. Unsigned integers are mostly used to describe registers with the same width. Signed integers habe one bit that serves as minus sign, so it is different in its structure.
It should also be noted that "int" is a platform dependent type. I.e. on one system it may occupy 16 bits, and on another it may occupy 32 bits. Whereas *int*_t declare a type of exactly X bits long.
Обсуждают сегодня