Post by pefv.. » Thu, 09 May 1991 02:03:33

Quote:>mantissa = comp_t & 0x1FFF
>exponent = comp_t & 0xE000

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

I would be delighted, actually, to learn that I'm wrong and have

Quote:>someone provide a more sensible explanation.


ticks = (double)((comp_t & 0x1fff) << 3 * (comp_t & 0xe000));

The reason your ldexp call is correct is that it is

mantissa times (8 to the power exponent)
or more literally
mantissa times (2 to the power (3 times exponent))

This can be done quicker with a left shift.  As K&R2 says,

        The value of E1<<E2 is E1 (interpreted as a bit pattern)
        left-shifted E2 bits; in the absence of overflow, this
        is equivalent to multiplication by 2  .



1. What is comp_t format?

I'm writing a program to read accounting records, and in acct(4) I see
that the fields that contain the CPU utilization figures are in
"comp_t" format, for which there is a typedef above that simply says
"13-bit fraction, 3-bit exponent".  Is there any more info available
(and maybe some examples) about this anywhere?

Warren Ring
Columbus, Ohio

2. White paper on NFS version 3?

3. HELP: Can't read comp_t filds in acct.h

4. reserve routing

5. acct.h: comp_t -> float conversion?

6. apache httpd.conf servername overiding virtualhost setting of the same?

7. Converting between comp_t and float/double on SunOS

8. Just attended new HP ISV porting seminar starting in various cities

9. comp_t