comp_t
Robert Dinse
nanook at eskimo.celestial.com
Sat May 11 09:57:00 AEST 1991
In article <9105060921.aa11316 at art-sy.detroit.mi.us>, chap at art-sy.detroit.mi.us (j chapman flack) writes:
# 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.
Actually this makes perfect sense. I found an include file on a
different system that had notes that were just a tad more explicit.
Specifically they stated that the exponent was base 8. Now, ldexp takes
an exponent in base 2, 2 to the third power is 8, and so that adjustment
of exponent * 3 does exactly what you need, effectively converting ldexp
from base 2 to base 8.
I am curious how you arrived at that formula, but now all things
considered it makes sense. Thanks for following up on my post!
More information about the Comp.unix.programmer
mailing list