CKTIS / C++
int — signed integer type
int is a built-in signed integer type that stores negative numbers, zero, and positive numbers. Its width is at least 16 bits; do not assume it is always 32 bits. Dividing two int values produces an integer result, and signed arithmetic overflow causes undefined behavior.
Version: C++23; repository compiler flag, production runtime not attested
Syntax
int name{value};int is a fundamental signed integer type. Use it to store whole numbers, such as counters and small quantities. The spellings int, signed int, and signed denote the same type. unsigned int is a distinct unsigned type, not another name for int.
The width of int is at least 16 bits and is implementation-defined. For width N, its range is −2^(N−1) through 2^(N−1)−1 inclusive; in C++23, this therefore includes at least −32768 through 32767. Do not assume a fixed width of 32 bits. An arithmetic operation on int whose result is outside that type's range causes undefined behavior—you cannot rely on values wrapping around.
When both operands have type int, / discards the fractional part of the quotient toward zero, while % computes the remainder. Division by zero is undefined. If the quotient is not representable in the result type, both / and % have undefined behavior.
In the example, total and groupSize are initialized when declared. Dividing 17 items into groups of 5 gives 3 complete groups and 2 remaining items, so the program prints 3 2. The eel.is source is an evolving working draft, not a frozen C++23 publication.
Examples
#include <iostream>
int main() {
int total{17};
int groupSize{5};
int groups{total / groupSize};
int remaining{total % groupSize};
std::cout << groups << ' ' << remaining << '\n';
}
Result
3 2
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.