A narrowing conversion changes a value to a type with a smaller range or less precision. The conversion is harmless when the value fits, but it can produce implementation-dependent danger or information loss when it does not. Decimal and hexadecimal literals can behave differently: -2'147'483'648 fits a signed int, while -0x8000'0000 can represent an out-of-range value before negation. Unsigned conversion uses modular arithmetic, so converting 0x8000'0000 to unsigned short can produce 0. TAKEAWAY: avoid narrowing conversions and avoid narrow types in arithmetic. section 5.4
double a = 1; // Harmless; value fits type signed short b = -1; // Harmless; value fits type signed int c = 0x8000'0000; // Dangerous; value too big for type signed int d = -0x8000'0000; // Dangerous; value too big for type signed int e = -2'147'483'648; // Harmless; value fits type unsigned short g = 0x8000'0000; // Loses information; has value 0
Compare harmless conversions with out-of-range signed values and an unsigned conversion that loses information. section 5.4


