CKTIS / C++
std::int32_t — an exactly 32-bit signed integer type
std::int32_t from <cstdint> aliases a signed integer type with exactly 32 bits and no padding bits. Its range is -2147483648 through 2147483647. Whether this alias is available depends on the implementation.
Version: C++23; repository compiler flag, production runtime not attested
Syntax
#include <cstdint>
std::int32_t value{42};std::int32_t, declared in <cstdint>, is an alias for an existing signed integer type, not a new distinct type. It has exactly 32 bits, no padding bits, and a two's complement representation. Its range is -2147483648 through 2147483647 inclusive.
The alias is optional: an implementation provides it if it has a corresponding exact-width type without padding bits. After including <cstdint>, the macro INT32_MAX lets you check availability with #ifdef. Plain int does not guarantee exactly 32 bits. Exact width also does not mean that sizeof(std::int32_t) == 4 on every platform, because a C++ byte need not contain 8 bits.
Use this alias when an exact width is required. If at least 32 bits is sufficient, consider std::int_least32_t; it need not have exactly 32 bits. Arithmetic still follows the usual integer promotion rules. Overflow of the signed type in which an operation is performed causes undefined behavior—do not assume wraparound.
The example subtracts 250 from 1200 and prints the result and the range limits through INT32_MIN and INT32_MAX. If the alias is unavailable, compilation deliberately stops. This entry targets C++23; the supplied reference points to an evolving standard draft, not a frozen C++23 publication.
Examples
#include <cstdint>
#include <iostream>
#ifndef INT32_MAX
#error "This example requires std::int32_t"
#else
int main() {
std::int32_t balance{1200};
balance -= 250;
std::cout << static_cast<long long>(balance) << '\n';
std::cout << static_cast<long long>(INT32_MIN) << ' ' << static_cast<long long>(INT32_MAX) << '\n';
}
#endif
Result
950 -2147483648 2147483647
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.