Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: All
Jun 2, 2000

Integers With Platform-Independent Width

The newly approved C99 standard defines a new header file called < inttypes.h >, which defines sets of typedef names for integer types. One of these sets defines integer types having certain exact widths:

 int8_t     int16_t     int32_t     int64_t

And their exact-width unsigned counterparts are:

 uint8_t    uint16_t    uint32_t    uint64_t

The names are rather intuitive. For example, int8_t is a signed integral type that occupies exactly eight bits. Likewise, uint8_t is an unsigned integral type that occupies exactly eight bits. Use these typedef names when you need integers whose widths are identical on every platform.

Danny Kalev
Thanks for your registration, follow us on our social networks to keep up-to-date