Subtracting floating-point numbers of large magnitude can result in that their small difference getting inaccurately represented or completely lost. This phenomenon is known as catastrophic cancellation.
For example, in the following piece of code, if the value returned by the timer is large, and the duration of the measured operation is small, subtracting the two timestamps after converting them to seconds can lead to loss of precision:
size_t start_ns = now();
// ... some operation
size_t end_ns = now();
double start_seconds = start_ns / 1e9;
double end_seconds = end_ns / 1e9;
double elapsed_seconds = end_seconds - start_seconds;
A better way to handle this problem is to perform subtraction before converting to floating-point number:
double elapsed_seconds = (end_ns - start_ns) / 1e9;