C++C++11C++14C++17C++20Introduction to C++

What Are Fixed Width Integer Types In Modern C++

In C++ development, integer variables can be decimal (base 10), octal (base 8) or hexadecimal (base 16). In addition to int, short int, long int, and long long int, there are fixed width integer types. Fixed-width integers are defined types with a fixed number of bits. In this post we will list them.

What are fixed width integer types in modern C++?

In addition to standard types in C++, there are fixed-width integers which are defined types in header <cstdint> with a fixed number of bits. Fixed-width integers are called as intN_t or intX_t integers where N or X represents number of bits reserved for that type. That means, these integer types guarantee a specific size in bits, and can be portable to any other platform. Mostly we use decimal variables which are in ranges from 0 to 4,294,967,295 but there are many different types of integers that allows developers use the memory wisely.

What are fixed width signed integer types in modern C++?

Fixed-width integers which are defined types in header <cstdint>, and these can be listed as below,

Here are signed with integer types:

Fixed Width Integer TypesDescription
int8_t8 bits signed integer type
int16_t16 bits signed integer type
int32_t32 bits signed integer type
int64_t64 bits signed integer type

Here are signed integer types ‘fastest form’:

Fixed Width Integer TypesDescription
int_fast8_t8 bits fast signed integer type
int_fast16_t16 bits fast signed integer type
int_fast32_t32 bits fast signed integer type
int_fast64_t64 bits fast signed integer type

Here are signed with integer types in ‘smallest form’:

Fixed Width Integer TypesDescription
int_least8_t8 bits smallest signed integer type
int_least16_t16 bits smallest signed integer type
int_least32_t32 bits smallest signed integer type
int_least64_t64 bits smallest signed integer type

and there is also maximum-width signed integer type:

Fixed Width Integer TypesDescription
intmax_tinteger type that has maximum-width

and a signed integer type that holds pointer:

Fixed Width Integer TypesDescription
intptr_tsigned integer type that holds pointer

What are fixed width unsigned integer types in modern C++

If you are sure that your integer variable is a zero or a positive number, you can use an unsigned version that doubles the highest integer number which can be used in that variable.

Here are unsigned with integer types in general form:

Fixed Width Integer TypesDescription
uint8_t8 bits unsigned integer type
uint16_t16 bits unsigned integer type
uint32_t32 bits unsigned integer type
uint64_t64 bits unsigned integer type

Here are unsigned with integer types in fastest form:

Fixed Width Integer TypesDescription
uint_fast8_t8 bits fast unsigned integer type
uint_fast16_t16 bits fast unsigned integer type
uint_fast32_t32 bits fast unsigned integer type
uint_fast64_t64 bits fast unsigned integer type

Here are signed with integer types in smallest form:

Fixed Width Integer TypesDescription
uint_least8_t8 bits smallest unsigned integer type
uint_least16_t16 bits smallest unsigned integer type
uint_least32_t32 bits smallest unsigned integer type
uint_least64_t64 bits smallest unsigned integer type

and there is also maximum-width unsigned integer type:

Fixed Width Integer TypesDescription
uintmax_tinteger type that has maximum-width

and unsigned integer type that holds pointer:

Fixed Width Integer TypesDescription
uintptr_tunsigned integer type that holds pointer

If you are looking more about Integer constants there are more details about them, https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Integer_Constants

What Are Fixed Width Integer Types In Modern C++ The C++ Builder Logo

C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, MacOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs.

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++17Language FeatureLearn C++

How To Use The SVG Image Format With Skia In C++ Builder

C++C++17Language FeatureLearn C++

How To Use Skia Images in C++ Builder?

C++C++17Code SnippetGame DevelopmentLanguage FeatureLearn C++

What Is Skia In Modern C++?

C++C++17Learn C++

How To Use Skia in C++ Builder 12?