microtime = time_camera.tv_sec * 1000000 + time_camera.tv_usec;
tv_sec
is a smaller integer type (time_t
, probably int
or long
), so
time_camera.tv_sec * 1000000
overflows. Use a suffix to give the constant the appropriate type
time_camera.tv_sec * 1000000ULL
In
microtime = time_camera.tv_sec;
microtime = microtime * 1000000;
the multiplication is performed at unsigned long long
, since one operand (microtime
) already has that type, so the other is converted to that.