I\'m just starting out in C++ (literally my second day) and I\'ve been assigned to calculate the ranges of the varying data types, signed and unsigned. The problem is, the way m
std::numeric_limits
You can get the actual values of these limits using these functions:
You substitute the appropriate type in place of T
, such as signed char
or unsigned char
.
The formulas for a signed number with N bits (using two's complement) are
The formulas for an unsigned number with N bits are
char
The char
has N = 8 bits. Let's verify these formulas with signed char
and unsigned char
.
signed char
unsigned char