Re: why I cannot stop this loop at 50 points? (code)
- From: Ben Bacarisse <ben.usenet@xxxxxxxxx>
- Date: Sat, 16 May 2009 15:18:58 +0100
blargg.ei3@xxxxxxxxxxxxx (blargg) writes:
Keith Thompson <kst-u@xxxxxxx> wrote:
lawrence.jones@xxxxxxxxxxx writes:[...]
James Dow Allen <jdallen2000@xxxxxxxxx> wrote:
Why not
find the hypothetical library that makes time() a
float and stamp it out:
It's not hypothetical: SAS/C for the IBM mainframe implements time_t as
double. (The system time-of-day clock has subsecond resolution, so it
makes some sense to expose that to C programs.)
One obvious disadvantage is that the resolution varies over time. For
times sufficiently close to the epoch, you can distinguish between one
yottasecond and the next. By now, the resolution (given FLT_RADIX ==
16 and DBL_MANT_DIG == 14, thus 56 bits of precision) is around 3.7
nanoseconds, and it will remain there for some time. If that's finer
than the resolution of the system time-of-day clock, I suppose that's
not a real problem. But I still think it would have been better to
use a large integer representing, say, a number of nanoseconds.
How is that much different than say using a nanosecond timebase and
dividing that value by 1e-9? Either way, once the time value gets
sufficiently large, you get less and less than nanosecond
resolution.
Yes, but you are not forced to divide by 1e9. For example if you
subtract two times you get nanosecond resolution for years to come. A
floating time (or two integer nansecond times divided by 1e9) slowly
loses resolution as time goes by.
And if you do need to divide, having the integer version lets you
decide how to do that. You could use a wider floating type, or an
arbitrary precision maths library. A constant resolution integer time
is simply a better design.
--
Ben.
.
- Follow-Ups:
- Re: why I cannot stop this loop at 50 points? (code)
- From: Ben Bacarisse
- Re: why I cannot stop this loop at 50 points? (code)
- From: blargg
- Re: why I cannot stop this loop at 50 points? (code)
- References:
- why I cannot stop this loop at 50 points? (code)
- From: FSX
- Re: why I cannot stop this loop at 50 points? (code)
- From: Richard
- Re: why I cannot stop this loop at 50 points? (code)
- From: pete
- Re: why I cannot stop this loop at 50 points? (code)
- From: FSX
- Re: why I cannot stop this loop at 50 points? (code)
- From: Beej Jorgensen
- Re: why I cannot stop this loop at 50 points? (code)
- From: James Dow Allen
- Re: why I cannot stop this loop at 50 points? (code)
- From: lawrence . jones
- Re: why I cannot stop this loop at 50 points? (code)
- From: Keith Thompson
- Re: why I cannot stop this loop at 50 points? (code)
- From: blargg
- why I cannot stop this loop at 50 points? (code)
- Prev by Date: Re: Integer Types
- Next by Date: Re: why I cannot stop this loop at 50 points? (code)
- Previous by thread: Re: why I cannot stop this loop at 50 points? (code)
- Next by thread: Re: why I cannot stop this loop at 50 points? (code)
- Index(es):
Relevant Pages
|