Data Types in C++
When you create a variable, you reserve some space in memory.
Different data types take up different amount of space.
Some of the fundamental data types in C++ are :
Different data types take up different amount of space.
Some of the fundamental data types in C++ are :
source : https://www.tutorialspoint.com/cplusplus/cpp_data_types.htm
Calculation for range of int :
1 int contains 4 bytes and 1 byte contains 8 bits
So, 1 int contains = 4x8 = 32 bits
n bits can have 2^n patterns
So, 32 bits have 2^32 = 4294967296, which is the range of unsigned int.
Size of data types can also vary by machine.
Comments
Post a Comment