acct.h: comp_t -> float conversion?

acct.h: comp_t -> float conversion?

Post by Choe Won Gy » Sat, 30 Jul 1994 13:57:22

 I wrote small tools for analyzing the /var/adm/pacct file, but I have a
problem.  How can I convert the comp_t numbers into usual float numbers?

In /usr/include/sys/acct.h,

 * Accounting structures;
 * these use a comp_t type which is a 3 bits base 8
 * exponent, 13 bit fraction ``floating point'' number.
typedef u_short comp_t;

struct  acct
        comp_t  ac_utime;               /* Accounting user time */
        comp_t  ac_stime;               /* Accounting system time */
        comp_t  ac_etime;               /* Accounting elapsed time */


Surely it seems that comp_t is not unsigned_short..

thanks in advance,



|    Nonlinear and Complex Systems Laboratory,                             |
|    Department of Physics,                                                |
|    Pohang University of Science and Technology.                          |
|    Sci. Bldg. 3 - 317A,    (Tel) 0562-279-5842    (FAX) 0562-279-3099    |


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

I sure hope someone can help me here.  I have been pulling my
hair out trying to figure out the comp_t fields described in
the sys/acct.h file.  Here is a run-down of what I have and
have done ...

        System type:  BSD variant (Apollo and Sun workstations).
        File to be read:  /usr/adm/acct.

        I can read all fields accept the comp_t fileds for
        the acct struct which is described in <sys/acct.h>.

        From the Docs:
        The comp_t field is declaired as a unsigned short in
        the acct structure.  The <sys/acct.h> file in the
        BSD4.3 distribution describes these entries as being
        a ''floating point`` number with a 3 bit base 8
        exponent and 13 bit fraction.

        Attemps (failures??):
        My first attempt was to "mask-off" the fraction and
        multiply in the exponent using pow(2.0,"the exponent").
        My second attempt was using bitfields to "move" the
        values into a float and then use the float as I needed.
        I have tried using the first and the last 3 bits of
        comp_t as the exponent. The only way I can compare my
        results is to use the UNIX sa command.

Well, that's it.  I hope someone can at least point me to
some PD program which uses this structure so I can be done
with this project (I'm just a poor sys_admin working for
hamburgers to get through school.

                                Brian G. Howard

2. Different errno for /bin/cc and /usr/5bin/cc

3. Conversion of Vax float to Sun float

4. Ecrix VXA-1 drive errors

5. VM/CMS float conversion to IEEE float for AIX?

6. driver DMA mem alloc question

7. Converting between comp_t and float/double on SunOS

8. Q: sed script to remove quotes

9. IBM->VAX floating point conversion

10. vms float -> ieee float

11. telnet <NL> -> <CR> conversion

12. ogg -> mp3 conversion -> perl pipe solution

13. float conversion problem