A quick detour - Data Types

Some data types, including some that you might not have seen.

A Quick recap

So basically, a data type is supposed to be something that tells the type of data you’re dealing with.

I’ll only be talking about Primitive data types today, as anything else would be too advanced for this beginner tutorial.

So here goes:

Data Type Explanation
bool Boolean
int Integer type
float Floating point
double Floating point, but with greater accuracy
void Valueless
char Character
wchar_t Wide Character

Detailed Explanations

bool Data Type

The bool data type is used for explicitly or implicitly declaring whether a particular value is true or false. It itself can be declared and initialised like this: bool var = false or bool var = true It has 1 bit of information.

int Data Type

The int data type is the one that most visitors of this site would be familiar with. It is used to store integer values that can vary from -2^8 to 2^7. It normally carries 4 bytes of information.

float Data Type

The float data type is used to store floating point, i.e., Decimal point values. It can carry 4 bits of information.

double Data Type

The double data type is used when float doesn’t give the accuracy you need. That’s becuase double can store 8 bytes of information.

void Data Type

void is somewhat interesting, because void is used when there is no info to be stored. To be more blunt, there is nothing it can store. Keeps you thinking on why exactly it’s called a data type, then, right?

char Data Type

char is used to store a single character. Therefore, it is 1 byte long.

wchar_t Data Type

Used to denote a wide character, for example, character sets that are older and predate UTF-8, and are also bigger than UTF-8. Don’t use it unless you need to.

Some Other Data Types

Here, I’ll talk about some Data types that I think are too advanced to include in the previous section. Feel free to skip this if don’t want to read it.

Character Types

Some other, not-so-basic character types are given below.

Data Types Description
char16_t Stores more than char, no less than 16 bits (2 bytes) of storage
char32_t Stores more than char16_t, no less than 32 bits (4 bytes of storage)
char64_t Stores more than char64_t, no less than 64 bits (8 bytes of storage)

Integer Types

Data Types Description
long int Stores more than int (At least 4 bytes)
long long int Stores more than long int (At least 8 bytes)

Any other Data type that I have not mentioned in here has a very niche usage, or I have not come across a good reason to include that Data type in here.