Skip to main content

Posts

Featured

Limitation of Integer type in programming languages

If you are a programmer, then you may know that the range of integer types are limited. For example, for a 64-bit compiler,  c++ int type occupies   4 byte. And the range of int is -2,147,483,648 to 2,147,483,647. Suppose you build a program that takes an integer, adds 1 to it and then returns the output to the user. #include <iostream> int main() { int num; std::cin>> num; std::cout<< (num + 1); return 0; } Everything is working fine as expected. The user gives a number and the program adds 1 to it in a second. But what if the user enters the highest number that the int type can take? In this case user enters 2,147,483,647. Output will be -2,147,483,648 . You know it right? But have you ever realized why this is happened? Why did the addition of the two numbers give us the highest negative number int can take? Let’s find it out – But before talking about 32-bit integer type ,let us think of a smaller fictional type say small...

Latest Posts

ISRO's webinar on INSPACe is further postponed

How can 2’s complement behave as a negation of a number?

ISRO postponed webinar on INSPACe

ISRO to conduct webinar on INSPACe

ISRO building IN-SPACe for private space industries

Doppler Effect and Light

Velocity composition law in relativity

Is the universe expanding?

Basis four vectors in spacetime: