How do I double timeval in C?

221 views Asked by At

I am very new to C and I have the following code where I want to double the timeval, how can I do this?

#include <time.h>

struct timeval t ={1, 10000}; 

while(1){
    //some code to use timeval 
    Here I need to double the timeval. Meaning if the timeval was 1.1 seconds, I need to make t = 2.2
    seconds. 
}
1

There are 1 answers

0
Some programmer dude On BEST ANSWER

You need to double both the microseconds and the seconds.

Then you need to check for overflow of the microseconds (if it's larger than one million) in which case you need to add another second and subtract one "second" from the microseconds.