Re: [AD] use double for al_current_time and al_rest? |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: Coordination of admins/developers of the game programming library Allegro <alleg-developers@xxxxxxxxxx>
- Subject: Re: [AD] use double for al_current_time and al_rest?
- From: Andrei Ellman <ae-a-alleg@xxxxxxxxxx>
- Date: Thu, 27 Dec 2007 18:14:18 +0100
- Organization: Wacko Software
Elias Pschernig wrote:
Should we change
unsigned long al_current_time(void)
void al_rest(long msecs)
to
double al_current_time(void)
void al_rest(double seconds)
and also have them both use seconds?
>
[...]
>
And I don't see any disadvantages right now..
Using a floating point value for timers is not a good idea because once
the exponent gets too large, the precision of the value to al_rest() for
decreases, and eventually, the current_time value will become so large
that the amount to rest() for will underflow. While underflow may not
happen for a long time, if someone wants to al_rest() for a
high-precision ammount of time, the actual time rested will be inconsistent.
> The advantages would be:
>
> - No implicit guarantee of providing milliseconds accuracy - I don't
> think we always can do that.
>
> - No limit to milliseconds resolution, when we actually often can do
> much better with all those high precision timers the OS provides these
> days.
>
> - Seconds as unit seems to be the least surprise, instead of arbitrarily
> using one of milli, micro or nano seconds requiring to check docs each
> time.
Why not just used a fixed-point number of seconds?
AE.