Simbody
3.6

These inline functions provide a fast and convenient way for doing arithmetic with the ugly Posix timespec struct. More...
Functions  
long long  SimTK::timespecToNs (const timespec &ts) 
Convert a time stored in a timespec struct to the equivalent number of nanoseconds (as a signed quantity). More...  
void  SimTK::nsToTimespec (const long long &ns, timespec &ts) 
Given a signed number of nanoseconds, convert that into seconds and leftover nanoseconds in a timespec struct. More...  
double  SimTK::nsToSec (const long long &ns) 
Given a count of nanosecond ticks as a signed 64 bit integer, return the same time interval as a double precision floating point number of seconds. More...  
long long  SimTK::secToNs (const double &s) 
Given a signed time interval as a double precision floating point number of seconds, return the same time interval as a count of nanosecond ticks in a signed 64 bit integer. More...  
These inline functions provide a fast and convenient way for doing arithmetic with the ugly Posix timespec struct.
Use them to convert the timespec to a long long integer number of nanoseconds, do arithmetic in that form, and then convert back. Negative times are handled correctly (they come up as the result of subtraction and comparisons).
We usually prefer to deal with times as a double precision floating point number of seconds and functions are provided for converting between nanoseconds and seconds in this format.

inline 
Convert a time stored in a timespec struct to the equivalent number of nanoseconds (as a signed quantity).

inline 
Given a signed number of nanoseconds, convert that into seconds and leftover nanoseconds in a timespec struct.

inline 
Given a count of nanosecond ticks as a signed 64 bit integer, return the same time interval as a double precision floating point number of seconds.
See Timespec/Nanosecond/Second Conversions for cautions.

inline 
Given a signed time interval as a double precision floating point number of seconds, return the same time interval as a count of nanosecond ticks in a signed 64 bit integer.
See Timespec/Nanosecond/Second Conversions for cautions.