summaryrefslogtreecommitdiff
path: root/timespec.h
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2015-06-05 11:03:21 -0700
committerGary E. Miller <gem@rellim.com>2015-06-05 11:03:21 -0700
commit8c8de4309249ed5a8af1115541ad375b74ebcd7a (patch)
tree1d2cd2367a443b65002fccd2b634c0b85df95b80 /timespec.h
parent957a206b0b618baf1db465bdd2161cf200a49459 (diff)
downloadgpsd-8c8de4309249ed5a8af1115541ad375b74ebcd7a.tar.gz
Revert a change to TSTONS() that caused loss of precision.
Using NS_IN_SEC instead of 1e9 in double math causes loss of precision.
Diffstat (limited to 'timespec.h')
-rw-r--r--timespec.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/timespec.h b/timespec.h
index d1ee3d3d..5fd7fe1e 100644
--- a/timespec.h
+++ b/timespec.h
@@ -94,8 +94,9 @@ static inline void TS_NORM( struct timespec *ts)
/* convert a timespec to a double.
* if tv_sec > 2, then inevitable loss of precision in tv_nsec
- 8 so best to NEVER use TSTONS() */
-#define TSTONS(ts) ((double)((ts)->tv_sec + ((ts)->tv_nsec / NS_IN_SEC)))
+ * so best to NEVER use TSTONS()
+ * WARNING replacing 1e9 with NS_TO_SEC casues loss of precision */
+#define TSTONS(ts) ((double)((ts)->tv_sec + ((ts)->tv_nsec / 1e9)))
#define TIMESPEC_LEN 22 /* required length of a timespec buffer */