Fixed width integer types (since C99) (2024)

C

Language
Headers
Type support
Program utilities
Variadic function support
Error handling
Dynamic memory management
Strings library
Algorithms
Numerics
Date and time utilities
Input/output support
Localization support
Concurrency support (C11)
Technical Specifications
Symbol index

[edit]

Type support

size_t

ptrdiff_t

nullptr_t

(C23)

NULL

max_align_t

(C11)

offsetof

Numeric limits
Fixed width integer types (C99)

[edit]

Contents

  • 1 Types
  • 2 Macro constants
    • 2.1 Signed integers: width
    • 2.2 Signed integers: minimum value
    • 2.3 Signed integers: maximum value
    • 2.4 Unsigned integers: width
    • 2.5 Unsigned integers: maximum value
  • 3 Function macros for minimum-width integer constants
  • 4 Format macro constants
    • 4.1 Format constants for the fprintf family of functions
    • 4.2 Format constants for the fscanf family of functions
  • 5 Example
  • 6 References
  • 7 See also

[edit] Types

Defined in header <stdint.h>

int8_t
int16_t
int32_t
int64_t
signed integer type with width of
exactly 8, 16, 32 and 64 bits respectively
with no padding bits and using 2's complement for negative values
(provided only if the implementation directly supports the type)
int_fast8_t
int_fast16_t
int_fast32_t
int_fast64_t
fastest signed integer type with width of
at least 8, 16, 32 and 64 bits respectively
int_least8_t
int_least16_t
int_least32_t
int_least64_t
smallest signed integer type with width of
at least 8, 16, 32 and 64 bits respectively
intmax_t maximum width integer type
intptr_t integer type capable of holding a pointer
uint8_t
uint16_t
uint32_t
uint64_t
unsigned integer type with width of
exactly 8, 16, 32 and 64 bits respectively
(provided only if the implementation directly supports the type)
uint_fast8_t
uint_fast16_t
uint_fast32_t
uint_fast64_t
fastest unsigned integer type with width of
at least 8, 16, 32 and 64 bits respectively
uint_least8_t
uint_least16_t
uint_least32_t
uint_least64_t
smallest unsigned integer type with width of
at least 8, 16, 32 and 64 bits respectively
uintmax_t maximum width unsigned integer type
uintptr_t unsigned integer type capable of holding a pointer

The implementation may define typedef names intN_t, int_fastN_t, int_leastN_t, uintN_t, uint_fastN_t, and uint_leastN_t when N is not 8, 16, 32 or 64. Typedef names of the form intN_t may only be defined if the implementation supports an integer type of that width with no padding. Thus, uint24_t denotes an unsigned integer type with a width of exactly 24 bits.

Each of the macros listed in below is defined if and only if the implementation defines the corresponding typedef name. The macros INTN_C and UINTN_C correspond to the typedef names int_leastN_t and uint_leastN_t, respectively.

[edit] Macro constants

Defined in header <stdint.h>

Signed integers: width

INT8_WIDTHINT16_WIDTHINT32_WIDTHINT64_WIDTH

(C23)(optional)

bit width of an object of type int8_t, int16_t, int32_t, int64_t (exactly 8, 16, 32, 64)
(macro constant)

INT_FAST8_WIDTHINT_FAST16_WIDTHINT_FAST32_WIDTHINT_FAST64_WIDTH

(C23)

bit width of an object of type int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t
(macro constant)

INT_LEAST8_WIDTHINT_LEAST16_WIDTHINT_LEAST32_WIDTHINT_LEAST64_WIDTH

(C23)

bit width of an object of type int_least8_t, int_least16_t, int_least32_t, int_least64_t
(macro constant)

INTPTR_WIDTH

(C23)(optional)

bit width of an object of type intptr_t
(macro constant)

INTMAX_WIDTH

(C23)

bit width of an object of type intmax_t
(macro constant)
Signed integers: minimum value

INT8_MININT16_MININT32_MININT64_MIN

minimum value of an object of type int8_t, int16_t, int32_t, int64_t
(macro constant)

INT_FAST8_MININT_FAST16_MININT_FAST32_MININT_FAST64_MIN

minimum value of an object of type int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t
(macro constant)

INT_LEAST8_MININT_LEAST16_MININT_LEAST32_MININT_LEAST64_MIN

minimum value of an object of type int_least8_t, int_least16_t, int_least32_t, int_least64_t
(macro constant)

INTPTR_MIN

minimum value of an object of type intptr_t
(macro constant)

INTMAX_MIN

minimum value of an object of type intmax_t
(macro constant)
Signed integers: maximum value

INT8_MAXINT16_MAXINT32_MAXINT64_MAX

maximum value of an object of type int8_t, int16_t, int32_t, int64_t
(macro constant)

INT_FAST8_MAXINT_FAST16_MAXINT_FAST32_MAXINT_FAST64_MAX

maximum value of an object of type int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t
(macro constant)

INT_LEAST8_MAXINT_LEAST16_MAXINT_LEAST32_MAXINT_LEAST64_MAX

maximum value of an object of type int_least8_t, int_least16_t, int_least32_t, int_least64_t
(macro constant)

INTPTR_MAX

maximum value of an object of type intptr_t
(macro constant)

INTMAX_MAX

maximum value of an object of type intmax_t
(macro constant)
Unsigned integers: width

UINT8_WIDTHUINT16_WIDTHUINT32_WIDTHUINT64_WIDTH

(C23)(optional)

bit width of an object of type uint8_t, uint16_t, uint32_t, uint64_t (exactly 8, 16, 32, 64)
(macro constant)

UINT_FAST8_WIDTHUINT_FAST16_WIDTHUINT_FAST32_WIDTHUINT_FAST64_WIDTH

(C23)

bit width of an object of type uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t
(macro constant)

UINT_LEAST8_WIDTHUINT_LEAST16_WIDTHUINT_LEAST32_WIDTHUINT_LEAST64_WIDTH

(C23)

bit width of an object of type uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t
(macro constant)

UINTPTR_WIDTH

(C23)(optional)

bit width of an object of type uintptr_t
(macro constant)

UINTMAX_WIDTH

(C23)

bit width of an object of type uintmax_t
(macro constant)
Unsigned integers: maximum value

UINT8_MAXUINT16_MAXUINT32_MAXUINT64_MAX

maximum value of an object of type uint8_t, uint16_t, uint32_t, uint64_t
(macro constant)

UINT_FAST8_MAXUINT_FAST16_MAXUINT_FAST32_MAXUINT_FAST64_MAX

maximum value of an object of type uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t
(macro constant)

UINT_LEAST8_MAXUINT_LEAST16_MAXUINT_LEAST32_MAXUINT_LEAST64_MAX

maximum value of an object of type uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t
(macro constant)

UINTPTR_MAX

maximum value of an object of type uintptr_t
(macro constant)

UINTMAX_MAX

maximum value of an object of type uintmax_t
(macro constant)

[edit] Function macros for minimum-width integer constants

INT8_CINT16_CINT32_CINT64_C

expands to an integer constant expression having the value specified by its argument and the type int_least8_t, int_least16_t, int_least32_t, int_least64_t respectively
(function macro)

INTMAX_C

expands to an integer constant expression having the value specified by its argument and the type intmax_t
(function macro)

UINT8_CUINT16_CUINT32_CUINT64_C

expands to an integer constant expression having the value specified by its argument and the type uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t respectively
(function macro)

UINTMAX_C

expands to an integer constant expression having the value specified by its argument and the type uintmax_t
(function macro)
#include <stdint.h>UINT64_C(0x123) // might expand to 0x123ULL or 0x123UL

[edit] Format macro constants

Defined in header <inttypes.h>

[edit] Format constants for the fprintf family of functions

Each of the PRI macros listed here is defined if and only if the implementation defines the corresponding typedef name.

Equivalent
for int or
unsigned int
DescriptionMacros for data types

[u]intx_t

[u]int_leastx_t

[u]int_fastx_t

[u]intmax_t

[u]intptr_t

doutput of a signed decimal integer valuePRIdxPRIdLEASTxPRIdFASTxPRIdMAXPRIdPTR
iPRIixPRIiLEASTxPRIiFASTxPRIiMAXPRIiPTR
uoutput of an unsigned decimal integer valuePRIuxPRIuLEASTxPRIuFASTxPRIuMAXPRIuPTR
ooutput of an unsigned octal integer valuePRIoxPRIoLEASTxPRIoFASTxPRIoMAXPRIoPTR
xoutput of an unsigned lowercase hexadecimal integer valuePRIxxPRIxLEASTxPRIxFASTxPRIxMAXPRIxPTR
Xoutput of an unsigned uppercase hexadecimal integer valuePRIXxPRIXLEASTxPRIXFASTxPRIXMAXPRIXPTR

[edit] Format constants for the fscanf family of functions

Each of the SCN macros listed in here is defined if and only if the implementation defines the corresponding typedef name and has a suitable fscanf length modifier for the type.

Equivalent
for int or
unsigned int
DescriptionMacros for data types

[u]intx_t

[u]int_leastx_t

[u]int_fastx_t

[u]intmax_t

[u]intptr_t

dinput of a signed decimal integer valueSCNdxSCNdLEASTxSCNdFASTxSCNdMAXSCNdPTR
iinput of a signed integer value (base is determined by the first characters parsed)SCNixSCNiLEASTxSCNiFASTxSCNiMAXSCNiPTR
uinput of an unsigned decimal integer valueSCNuxSCNuLEASTxSCNuFASTxSCNuMAXSCNuPTR
oinput of an unsigned octal integer valueSCNoxSCNoLEASTxSCNoFASTxSCNoMAXSCNoPTR
xinput of an unsigned hexadecimal integer valueSCNxxSCNxLEASTxSCNxFASTxSCNxMAXSCNxPTR

[edit] Example

See also C++ compatibility note regarding spaces before format macros used in this example.

Run this code

#include <inttypes.h>#include <stdio.h>int main(void){ printf("%zu\n", sizeof(int64_t)); printf("%s\n", PRId64); printf("%+" PRId64 "\n", INT64_MIN); printf("%+" PRId64 "\n", INT64_MAX); int64_t n = 7; printf("%+" PRId64 "\n", n);}

Possible output:

8lld-9223372036854775808+9223372036854775807+7

[edit] References

  • C23 standard (ISO/IEC 9899:2024):
  • 7.8.1 Macros for format specifiers (p: TBD)
  • 7.18 Integer types <stdint.h> (p: TBD)
  • C17 standard (ISO/IEC 9899:2018):
  • 7.8.1 Macros for format specifiers (p: 158-159)
  • 7.18 Integer types <stdint.h> (p: 212-216)
  • C11 standard (ISO/IEC 9899:2011):
  • 7.8.1 Macros for format specifiers (p: 217-218)
  • 7.18 Integer types <stdint.h> (p: 289-295)
  • C99 standard (ISO/IEC 9899:1999):
  • 7.8.1 Macros for format specifiers (p: 198-199)
  • 7.18 Integer types <stdint.h> (p: 255-261)

[edit] See also

  • Arithmetic types

C++ documentation for Fixed width integer types

C++ documentation for User-defined literals (formatting macros note)

Fixed width integer types (since C99) (2024)

FAQs

What are fixed width integer types? ›

Fixed-width integers are integral types with a fixed number of bits. The C++ standard only specifies a minimum byte count for types such as short , int and long . Fixed-width integers guarantee a specific size, but their use can have an impact on portability, since they are not supported by all platforms.

What is the size of int type according to C99 standard? ›

C99 provides a stdint. h header file that defines integer types with known size independent of the machine architecture. So in C99, you can use int8_t instead of signed char to guarantee a signed type that holds exactly 8 bits, or uint64_t instead of unsigned long long to get a 64-bit unsigned integer type.

What is integer width? ›

The width, precision, or bitness of an integral type is the number of bits in its representation. An integral type with n bits can encode 2n numbers; for example an unsigned type typically represents the non-negative values 0 through 2n−1.

What is int16_t in C? ›

The int16_t data type is guaranteed to be 16 bits wide, no matter what compiler implementation you are using. The width of the int data type, as well as other built-in integral data types, can and does vary from one compiler implementation to another. In other words, the size of an int is implementation-defined.

What are the 4 integer data types? ›

Integers: These are of four types: byte , short , int , long . It is important to note that these are signed positive and negative values. Signed integers are stored in a computer using 2's complement.

What are examples of integer data types? ›

Integer data types are used to store a whole number without decimals, like 35, -50, or 1345000. The integer data type has two categories: Signed integers - can store both positive and negative values. Unsigned integers - can only store non-negative values.

What is integer with example? ›

An integer (pronounced IN-tuh-jer) is a whole number (not a fractional number) that can be positive, negative, or zero. Examples of integers are: -5, 1, 5, 8, 97, and 3,043.

What is data format fixed width? ›

Data in a fixed-width text file is arranged in rows and columns, with one entry per row. Each column has a fixed width, specified in characters, which determines the maximum amount of data it can contain. No delimiters are used to separate the fields in the file.

What is an example of an integral data type? ›

The int data type is used to represent integers. For example, to create an int variable to hold a value 5, we write the following: The num variable is now an int with a value of five. Here, we have created five variables, all of the int type, and initialized to zero.

What are the 32 data types in C? ›

Main types
TypeMinimum size (bits)Format specifier
int signed signed int16%i or %d
unsigned unsigned int16%u
long long int signed long signed long int32%li or %ld
unsigned long unsigned long int32%lu
10 more rows

How large is an int? ›

4 bytes

What is the difference between int and int32_t? ›

In C and C++, int has at least 16 bits. Usually, on common 32-bit and 64-bit architectures, it has 32 bits. The language standards permit it to have any size greater or equal to 16 bits. On the other hand, int32_t has exactly 32 bits.

What is an integer type in Ada? ›

In Ada, an integer type is not specified in terms of its machine representation, but rather by its range. The compiler will then choose the most appropriate representation. Another point to note in the above example is the My_Int'Image (I) expression.

What are the 4 types of integer data type in Python? ›

For instance, Python has several built-in data types, including numeric types (int, float, complex), string (str), boolean (bool), and collection types (list, tuple, dict, set).

What are the three types of integer representation? ›

Concerning the representation of integers in computer programming, there are two main methods for the representation. The first method is signed integers, and the second method is unsigned integers. A signed integer is a 32-bit datum that can hold positive and negative numbers, including a zero.

What are the NIM integer types? ›

Nim has these integer types built-in: int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64. Most often integers are used for counting objects that reside in memory, so int has the same size as a pointer.

References

Top Articles
Rosemary Mashed Sweet Potatoes with Shallots Recipe
Hotels in Myrtle Beach from $40 - Find Cheap Hotels with momondo
Ucsf Ilab
Hallmark White Coat Ceremony Cards
Adventhealth Employee Handbook 2022
Ncqa Report Cards
Fnv Mr Cuddles
Jocko Joint Warfare Review
Heat Pump Repair Horseshoe Bay Tx
Craigslist Folkston Ga
Jocelyne Mirando
Aces Charting Ehr
Valeriewhitebby Footjob
Chelsea Marie Boutique
2320 Pioneer Rd
Nancy Pazelt Obituary
Church Bingo Halls Near Me
Best Amsterdam Neighborhoods for Expats: Top 9 Picks
Joy Ride 2023 Showtimes Near Amc Ward Parkway
The Athenaeum's Fan Fiction Archive & Forum
Elemental Showtimes Near Sedaliamovies
Benjamin Hilton co*ck
Aleksandr: Name Meaning, Origin, History, And Popularity
Top Songs On Octane 2022
Desi Cinemas.com
Reasonabiu
Wolf Of Wall Street Tamil Dubbed Full Movie
Pull And Pay Middletown Ohio
Wmu Academic Calendar 2022
Walgreens Pharmacy On Jennings Station Road
Shaw Funeral Home Vici Oklahoma
Lux Nails Columbia Mo
Horoscope Daily Yahoo
Megan Montaner Feet
T&J Agnes Theaters
Rbgfe
Helixnet Rfums
Scarabaeidae), with a key to related species – Revista Mexicana de Biodiversidad
600 Aviator Court Vandalia Oh 45377
Www.1Tamilmv.cfd
Stephanie Ruhle's Husband
Craigslist Cars Merced Ca
Htmp Hilton
About Baptist Health - Baptist Health
Sams Warehouse Jobs
Skip The Games Mil
Dive Sports Bars Near Me
The 7 best games similar to Among Us for Android - Sbenny’s Blog
The Eye Doctors North Topeka
Intervallfasten 5/2: Einfache Anfänger-Anleitung zur 5:2-Diät
Redbox Walmart Near Me
Right Wrist Itching Superstition
Latest Posts
Article information

Author: Saturnina Altenwerth DVM

Last Updated:

Views: 5356

Rating: 4.3 / 5 (64 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Saturnina Altenwerth DVM

Birthday: 1992-08-21

Address: Apt. 237 662 Haag Mills, East Verenaport, MO 57071-5493

Phone: +331850833384

Job: District Real-Estate Architect

Hobby: Skateboarding, Taxidermy, Air sports, Painting, Knife making, Letterboxing, Inline skating

Introduction: My name is Saturnina Altenwerth DVM, I am a witty, perfect, combative, beautiful, determined, fancy, determined person who loves writing and wants to share my knowledge and understanding with you.