Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Jan 2005 20:05:45 +0100
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        Chuck Swiger <cswiger@mac.com>
Cc:        current@freebsd.org
Subject:   Re: Anybody involved with ISO C standardization ? 
Message-ID:  <34097.1106334345@critter.freebsd.dk>
In-Reply-To: Your message of "Fri, 21 Jan 2005 14:01:48 EST." <41F1519C.1090600@mac.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <41F1519C.1090600@mac.com>, Chuck Swiger writes:
>Poul-Henning Kamp wrote:
>> In message <41F14659.8040003@mac.com>, Chuck Swiger writes:
>[ ... ]
>> Resolution of 2 nanoseconds.
>> 
>> 	To get seconds you have to do a 64 bit divide by 500000000 ?
>> 
>> 	Anyone here heard about binary computers ?
>> 
>> 	Binary fractions please, that we we can simply shift way the bits
>> 	we don't want:
>> 
>> 			seconds = longtime >> 29;
>> 
>> 	(For some value of 29.)
>
>Indeed.  Some clever person might decide to power of two which was a multiple 
>of 8 or 16 or so, so that you don't even have to shift bits, and you end up 
>with something that resembles (struct timeval).  An integral timer with a 
>resolution of 1 tick = 1 second has a lot going right for it.

The problem is that if you use 32 bits, then 64 bits don't stretch far
enough, and if you use 24 bits you don't get enough resolution.

My personal preference would be

struct {
	signed 64+ bits:	integer part.
	unsigned 32+ bits:	fraction part.
}


-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?34097.1106334345>