Is conversion int -> unsigned long long defined by the standard
I can't find the exact specification of how int value is converted to unsigned long long in the standard. Various similar conversions, such as int -> unsigned, unsigned -> int (UB if negative), unsigned long long -> int, etc. are specified For example GCC, -1 is converted to 0xffffffffffffffff , not to 0x00000000ffffffff . Can I rely on this behavior? Yes, this is well defined, it is basically adding max unsigned long long + 1 to -1 which will always be max unsigned long long . This is covered in the draft C++ standard section 4.7 Integral conversions which says: If the destination type is