Why do we use the letter  “L” in C/C++

The letter “L” in C/C++ is called a long constant and most of the time it is written in capital letter “L” so that we don’t get confused with small letter l and 1 ONE

Basically, the purpose of using the letter “L” is to overcome the overflow that usually happens in a 16-bit machine

But, why only a 16-bit machine

Because in a 16-bit machine, the gap between int and long int is huge

Nowadays, people won’t use a 16-bit machine instead they use a 32-bit machine or 64-bit machine

In reality, the 16-bit machine has int range from  -32,768 to 32,767 which is disgustingly so, small

As a result, in a 16-bit machine the programmer usually, switches from low range to high range by using the letter “L” which was the jackpot in the olden days

At this time, we don’t use the letter “L” in most of the programs because, in a 32-bit machine, the range of int is the same as the long int

That is, fairly large enough for normal tasks

At the present time, C99 has introduced the new standard integer types called long long int and unsigned long long int to support newer 64-bit processor

By and large, it was introduced because of the growing demand for large integers in sum, to support 64-bit arithmetic

To point out, the long long type is required at least 64-bit wide to use the range the range-2^{63} that is -9,223,372,036,854,775,807 to 2^{63}-1 that is  -9,223,372,036,854,775,807

Here are some data types range for 16-bit, 32-bit, and 64-bit machine

16-bit machine

Data typeLowHigh
short int-32.76832,767
unsigned short int065,535
int-32,76832,767
unsigned int065,535
long int-2,147,483,6482,147,483,647
unsigned long int04,294,967,295

32-bit machine

Data typeLowHigh
short int-32,76832,767
unsigned short int065,535
int-2,147,483,6482,147,483,647
unsigned int04,294,967,295
long int-2,147,483,6482,147,483,647
unsigned long int018,446,744,073,709,551,615

64-bit machine

Data typeLow High
short int-32,76832,767
unsigned short int065,535
int-2,147,483,6482,147,483,647
unsigned int04,294,967,295
long int-9,223,372,036,854,775,8089,223,372,036,854,775,807
unsigned long int018,446,744,073,709,551,615

Mohammed Anees

Hey there, welcome to aneescraftsmanship I am Mohammed Anees an independent developer/blogger. I like to share and discuss the craft with others plus the things which I have learned because I believe that through discussion and sharing a new world opens up

Leave a Reply

Your email address will not be published.