math - (7 - 12) mod 24 equals 19 but in C++ it equals 4294967291 -
this question has answer here:
if google (7 - 12) mod 24 answer 19.
when c++ 4294967291
uint32_t hour = (7 - 12) % 24; // hour = 4294967291 if try int32_t
int32_t hour = (7 - 12) % 24; // hour = -5
(7 - 12) % 24 signed expression, , assigning unsigned int makes see different result
in c % remainder operation (7 - 12) % 24 = -5
unsigned(-5) = 4294967291 // since 4294967291 + 5 = 4294967296 while google , python uses mathematics modulus operation, result 19. , 19 + 5 = 24
Comments
Post a Comment