James Kanze
10/28/2008 9:31:00 AM
On Oct 26, 10:40 pm, Ian Collins <ian-n...@hotmail.com> wrote:
> red floyd wrote:
> > Joe wrote:
> >> I'm trying to add the current time + a randomly generated
> >> time w/ millisecond precision, but the numbers aren't
> >> making sense.
> >> If I add rand_time + now_time on my calculator, I get a
> >> different result than what's in sched_time. Anyone see what
> >> I'm doing wrong?
> > Yeah, you're using floats, which on most platforms don't
> > have enough precision to deal with your data. Try using
> > doubles instead.
> Or long long if your system has it.
If his system has gettimeofday, it has long long:-).
Personally, of course, I'd have just stuck with the timeval;
it's not that difficult to do a correct addition in base
1000000 (since you're pretty much guaranteed that adding two
values < 1000000 will not overflow).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34