[ntp:questions] Re: NTP4 has 3 different time formats! Namly (32, 64, 128) bits wide
Richard B. Gilbert
rgilbert88 at comcast.net
Wed Jul 19 08:34:22 UTC 2006
Terje Mathisen wrote:
> Richard B. Gilbert wrote:
>> Ulrich Windl wrote:
>>> Talking about 128bit time formats or so: With today's computing power
>>> think of MP3 decoders), a switch to BCD coded time in 128 bit should be
>>> 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
>> 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
I was thinking of the cost of doing all the arithmetic in BCD. The NTP
timestamps are exchanged between systems for the purpose of
synchronizing to UTC; there is no advantage to exchanging them in BCD.
They do not have to be "people readable"!
More information about the questions