Example 1: how maany bytes in an int in C
[8-bit] signed char: -127 to 127
[8-bit] unsigned char: 0 to 255
[16-bit]signed short: -32767 to 32767
[16-bit]unsigned short: 0 to 65535
[32-bit]signed long: -2147483647 to 2147483647
[32-bit]unsigned long: 0 to 4294967295
[64-bit]signed long long: -9223372036854775807 to 9223372036854775807
[64-bit]unsigned long long: 0 to 18446744073709551615
Example 2: c variable types
char 1 byte -128 to 127 or 0 to 255
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
int 2 or 4 bytes -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295
short 2 bytes -32,768 to 32,767
unsigned short 2 bytes 0 to 65,535
long 8 bytes or (4bytes for 32 bit OS) -9223372036854775808 to 9223372036854775807
unsigned long 8 bytes 0 to 18446744073709551615
Example 3: what is a long long int in c
#include
#include
#include
#define FailedToEducate 101
#define Success 400
int main(void) {
/*
A long int is:
32-bit compiler:
MIN: -2,147,483,648
MAX: 2,147,483,647
unsigned MAX: 4,294,967,295
64-bit compiler:
MIN: -9,223,372,036,854,775,808
MAX: 9,223,372,036,854,775,807
unsigned MAX: 18,446,744,073,709,551,615
Therefore...a long int will either be
-2,147,483,648 and 2,147,483,647 for a 32-bit compiler
or -9,223,372,036,854,775,808 and
9,223,372,036,854,775,807 for a 64-bit compiler,
whilst a long long int will just be
-9,223,372,036,854,775,808 and
9,223,372,036,854,775,807
I hope this made sense!
*/
bool userUnderstands=true;
if(userUnderstands) {
exit(Success);
} else {
exit(FailedToEducate);
}
}