Use macros for conversion values
#include <math.h>
+#define MICROSECONDS_PER_SECOND 1E6
+#define NANOSECONDS_PER_SECOND 1E9
+#define NANOSECONDS_PER_MICROSECOND 1E3
+
#ifdef _WIN32
#include <Windows.h>
#define END_TIMER(var) \
LARGE_INTEGER end; \
QueryPerformanceCounter(&end); \
- const long double var = \
- ((long double)(end.QuadPart - start.QuadPart)) / freq.QuadPart * 1E6
+ const long double var = ((long double)(end.QuadPart - start.QuadPart)) / \
+ freq.QuadPart * MICROSECONDS_PER_SECOND
#else // !defined(_WIN32)
elapsed.tv_sec = end.tv_sec - start.tv_sec; \
if (elapsed.tv_nsec < 0) { \
elapsed.tv_sec--; \
- elapsed.tv_nsec = 1E9 + elapsed.tv_nsec; \
+ elapsed.tv_nsec = NANOSECONDS_PER_SECOND + elapsed.tv_nsec; \
} \
- const long double var = (elapsed.tv_sec * 1E9 + elapsed.tv_nsec) / 1E3
+ const long double var = \
+ (elapsed.tv_sec * NANOSECONDS_PER_SECOND + elapsed.tv_nsec) / \
+ NANOSECONDS_PER_MICROSECOND
#endif
