[ntp:questions] Re: NTP4 has 3 different time formats! Namly (32, 64, 128) bits wide

Terje Mathisen terje.mathisen at hda.hydro.com
Wed Jul 19 06:03:25 UTC 2006


Richard B. Gilbert wrote:
> Ulrich Windl wrote:
>> Talking about 128bit time formats or so: With today's computing power 
>> (just
>> think of MP3 decoders), a switch to BCD coded time in 128 bit should be
>> sufficient:
>> Byte#: 1 2  3  4  5  6  7  8  910 111213 141516
>> Value:2006-07-18 09:26:13.12 1234 567890 123456
>>
>> So you'd have significant sub-picosecond resolution and peace until year
>> "9999".
>>
>> Regards,
>> Ulrich
> 
> Do YOU want to write the code to manipulate that format?  It looks like 
> a nightmare to me!

Not at all! It is in effect identical to standard ISO format, plus the 
fractional part, except for the two-to-one compression achieved by 
storing in BCD instead of ASCII, but that particular conversion is of 
course trivial.

BTW, I have written code to convert both ways, between ISO and Unix/NTP 
seconds, and it is the seconds-to-ISO operations which is the tough one: 
The naive code takes several hundred clock cycles to do this, while my 
version did it close to an order of magnitude faster. :-)

For the ascii/bcd fractional part I have also invented a way to convert 
a 32-bit unsigned number from binary to ascii (the reverse is easy of 
course) in something like 30-50 clock cycles. AMD stole/borrowed this 
code (or about 95% of it), without attribution, for their optimization 
guide.

Terje

-- 
- <Terje.Mathisen at hda.hydro.com>
"almost all programming can be viewed as an exercise in caching"




More information about the questions mailing list