Nick Ing-Simmons <[EMAIL PROTECTED]> writes:

> Dan Sugalski <[EMAIL PROTECTED]> writes:
> >At 10:55 AM 8/2/00 +0200, Gisle Aas wrote:
> >>All functions that return time values (seconds since epoch) should use
> >>floating point numbers to return as much precision as the platform
> >>supports.  All functions that take time values as arguments should
> >>work for fractional seconds if the platform supports it.
> >
> >Floats have resolution issues that exacerbate sub-second resolution issues.
> 
> As an engineer I would really like to know when you are going to 
> run out of precision in double - that is forty something bits of mantissa.
> That is more precision than you have in the real world.

If I measure the duration of something with code like this:

   my $before = time;

   do_something();

   my $duration = time - $before;
   print "$duration";

Then the use of double will limit the precision to something like 1e-6
sec.  I'm not sure that this is enough for the future, but I don't
really know.  What is the precision of the real world?

I used this simple script to experiment with double time precision:

   $prec = shift || 6;
   die if $prec < 2;
   
   my $t = int(time) . "." . ("0" x ($prec - 2));
   
   my $t1 = $t . "34";
   my $t2 = $t . "35";
   
   printf "$t2 - $t1 = %.4e\n", $t2 - $t1;

Perhaps this only measure how precise strtod() is?

--Gisle

Reply via email to