Your clock_t seems to be an unsigned 64-bit type.
You take a tick - tock where the tock was measured after the tick , so if there is any difference between them at all, it will try to create a negative number, but since it is an unsigned type that wraps around to become something close to the largest the number that can be represented in this type.
Obviously, you really want to use tock-tick .
source share