So I need to do some precision timing and am endeavoring to use tv_sec and tv_usec. Right now I, super messily, have a vector of my own home-rolled Tuple class, holding both secs and microsecs.
The issue here is... if i want to say... get the oldest of the entries in my vector, I have to do super hairy and gross comparisons between the values in the tuples.
I'd really like to combine tv_sec and tv_usec into a single value to store. This would make comparison very easy.
But how does one do this safely? Is this attempt below going to blow up in my face for certain values, for example?
gettimeofday(&tv, NULL);
time_t secs = tv.tv_sec;
time_t msecs = tv.tv_usec;
double the_answer = tv_sec + (1.0/1000000) * tv_usec; //ehhhh? Maybe?
I spose the question boils down to - will overflow/act weird/ruin me if I use it:
double the_answer = tv_sec + (1.0/1000000) * tv_usec; //ehhhh? Maybe?