Let's say I have the following code fragment in C++:
int64_t a = VALUE;
uint64_t b = a;
int64_t c = b;
Is there a VALUE for which a != c?
Let's say I have the following code fragment in C++:
int64_t a = VALUE;
uint64_t b = a;
int64_t c = b;
Is there a VALUE for which a != c?
Is there a VALUE for which
a != c?
Yes, theoretically any value less than 0 will cause you an issue. With a value less than 0, b will get a value greater than std::numeric_limits<int64>::max() and that means that there will be an implementation defined conversion from b to c.
For standard desktop machines where all integers are two's complement, then a will equal c. For a machine where signed and unsigned integers have different complement's, a may/will not equal c.
No, all integer types are two's complement so the value will be preserved.