D Programming Language 1.0

Last update Mon Dec 31 10:53:29 2012


D constrains integral types to specific sizes. But efficiency of different sizes varies from machine to machine, pointer sizes vary, and the maximum integer size varies. stdint offers a portable way of trading off size vs efficiency, in a manner compatible with the stdint.h definitions in C.

The exact aliases are types of exactly the specified number of bits. The at least aliases are at least the specified number of bits large, and can be larger. The fast aliases are the fastest integral type supported by the processor that is at least as wide as the specified number of bits.

The aliases are:

Exact Alias Description At Least Alias Description Fast Alias Description
int8_t exactly 8 bits signed int_least8_t at least 8 bits signed int_fast8_t fast 8 bits signed
uint8_t exactly 8 bits unsigned uint_least8_t at least 8 bits unsigned uint_fast8_t fast 8 bits unsigned

int16_t exactly 16 bits signed int_least16_t at least 16 bits signed int_fast16_t fast 16 bits signed
uint16_t exactly 16 bits unsigned uint_least16_t at least 16 bits unsigned uint_fast16_t fast 16 bits unsigned

int32_t exactly 32 bits signed int_least32_t at least 32 bits signed int_fast32_t fast 32 bits signed
uint32_t exactly 32 bits unsigned uint_least32_t at least 32 bits unsigned uint_fast32_t fast 32 bits unsigned

int64_t exactly 64 bits signed int_least64_t at least 64 bits signed int_fast64_t fast 64 bits signed
uint64_t exactly 64 bits unsigned uint_least64_t at least 64 bits unsigned uint_fast64_t fast 64 bits unsigned

The ptr aliases are integral types guaranteed to be large enough to hold a pointer without losing bits:

Alias Description
intptr_t signed integral type large enough to hold a pointer
uintptr_t unsigned integral type large enough to hold a pointer

The max aliases are the largest integral types:

Alias Description
intmax_t the largest signed integral type
uintmax_t the largest unsigned integral type

Walter Bright, http://www.digitalmars.com

Public Domain