Skip to content

Commit 18e15e2

Browse files
cypheongallais
authored andcommitted
[ fix ] Cast CLOCKS_PER_SEC to float before division
The cast to float needs to happen before the division, otherwise integer division will be performed, and as a result `CLOCKS_PER_NSEC` will always be 0 if `CLOCKS_PER_SEC` < `NSEC_PER_SEC`.
1 parent 2a4197e commit 18e15e2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

support/refc/clock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "clock.h"
22

33
#define NSEC_PER_SEC 1000000000
4-
#define CLOCKS_PER_NSEC ((float)(CLOCKS_PER_SEC / NSEC_PER_SEC))
4+
#define CLOCKS_PER_NSEC ((float)CLOCKS_PER_SEC / NSEC_PER_SEC)
55

66
Value *clockTimeMonotonic()
77
{

0 commit comments

Comments
 (0)