comp_t

j chapman flack chap at art-sy.detroit.mi.us
Mon May 6 23:21:37 AEST 1991


In article <512 at eskimo.celestial.com> nanook at eskimo.celestial.com (Robert Dinse) writes:
>"comp_t", which is packed into an unsigned short (16 bits). The
>comments say:
>
>	/* 13-bit fraction, 3-bit exponent */

I just messed with that recently myself.  By running a bunch of commands that
took known amounts of time (sleep(1) is handy for that) and trying to make
sense of the resulting comp_ts, I came up with the following theory:

mantissa = comp_t & 0x1FFF
exponent = comp_t & 0xE000

double ticks = ldexp( (double)mantissa, 3*exponent)

The extra factor of 3 in the exponent bothers me, but it was consistent with
the various values I tried.  You'll probably want to run a number of trials
yourself.  I would be delighted, actually, to learn that I'm wrong and have
someone provide a more sensible explanation.

Wouldn't it be nice if AT&T's comment included the information that needs
to be included?
-- 
Chap Flack                         Their tanks will rust.  Our songs will last.
chap at art-sy.detroit.mi.us                                   -Mikos Theodorakis

Nothing I say represents Appropriate Roles for Technology unless I say it does.



More information about the Comp.unix.programmer mailing list