Smaller than milliseconds?

Dar Scott dsc at swcp.com
Fri Jul 11 00:41:00 EDT 2003


On Thursday, July 10, 2003, at 09:12 PM, Nelson Zink wrote:

>> But do you have any reason to believe the processor clock and the long
>> seconds clock are not the same?
>
> Generally no, but strictly? I suppose I do. My long seconds are being
> displayed to 20 magnitudes of precision (with proper numberFormat
> adjustment). Either an alien technology has taken up residence in my 
> machine
> or something's screwy. I'm betting on the later.

The results of many operations and functions are internally double 
precision floating point numbers.  They are converted to strings when 
they need to be.  We can do much of our scripting without knowing or 
caring.  The floating point representation is binary.  There are 52 
bits in the precision plus an invisible bit for the left most one (for 
non-zero values).

The current date-time in seconds is about 1,058,000,000.  (1Gs = 32 
years, 1 year = 31 Ms, 1Ms = 11 1/2 days, 1ks = 17 minutes, approx.)  
The floating point number can represent about 16 digits.  That means 
you can't do better than about 100 ns (with the current number scheme).

I think we are seeing 1 microsecond resolution on OS X and 1 ms 
resolution on XP.  All those extra digits are from the binary to 
decimal conversion and are not meaningful, that is, not meaningful in 
time, but are predictable meaning they are worthless to as random bits. 
  (I think 1 microsecond 'long seconds' resolution is a reasonable goal 
for all platforms for the time being.)

You can collect some random bits using the long seconds, I think, but I 
don't think you want to base it on how long it takes to execute some 
code.  You might want to harvest it from operator interactions and if 
you don't have enough of those, from Internet response times.  The 
number of bits you can harvest depends on your estimate of 
predictability.

If we are really seeing only 1 ms on XP, then you have less bits to 
harvest and it will take you longer to get enough for a seed; save 'em 
up.

Dar Scott

******************************************************************
   Dar Scott Consulting     Programming Services     dsc at swcp.com
******************************************************************




More information about the metacard mailing list