Uses of "float:16" ?

John Mashey mash at mips.UUCP
Mon Oct 7 04:03:17 AEST 1985


> > > Then you can define
> > > 
> > > float foo:16;
> > > 
> > > if you really think you can do something useful with 16-bit floats. Someone
> > > must use them for something...
> > 
> > Just such a construct is used in the accounting software in many UNIX System
> > kernels.  It seems to suffice for the application.
> 
> Great, a violation of the C language spec in the kernel.

Not to worry.  There's no float foo:16 definition per se; what's there is
DMR's	typedef ushort compt_t; followed by code that does arithmetic in
longs, then packs the results into the comp_t, with 3-bit exponent and
13 bit mantissa.  This was done because:
	a) You need more than 16 bits to represent the observed numbers.
	b) You want both good precsision for smaller numbers, for doing
	measurement studies, and at least gross precision for larger ones,
	for system accounting. Good short-float application.
	c) The process accounting system can generate much data; this was
	especially a concern on the PDP 11/70s current when this code was
	written; anything was worth keeping the size down.
	d) Using the comp_t code lets you keep the size of (struct acct)
	to 32 bytes. It is moderately helpful that this size be a power of
	2 so that the struct never cross disk buffer boundaries.
-- 
-john mashey
UUCP: 	{decvax,ucbvax,ihnp4}!decwrl!mips!mash
DDD:  	415-960-1200
USPS: 	MIPS Computer Systems, 1330 Charleston Rd, Mtn View, CA 94043



More information about the Comp.lang.c mailing list