c++ – C ++ integer data types


What is the difference between long intint , signed char__int8 , etc. from here https://msdn.microsoft.com/ru-ru/library/s3f49ktz.aspx and why do some functions return long int and others return int ?


Data types like int and long int can have different sizes depending on the architecture. The standard only limits their relative size, for example, sizeof(int) <= sizeof(long int) . Since the inequality is not strict, the sizes may coincide.

On the x86 / x64 platform, these types have a very specific size, for example, sizeof(int) == 4 . However, the size may differ on other architectures.

The difference between int and long int historical. On a 16-bit platform, sizeof(int) == 2 and sizeof(long int) == 4 . Accordingly, for the functions of those times, the difference is significant.

Data types __int16 , __int32 are guaranteed to be 16 and 32 bits, regardless of architecture.

Scroll to Top