[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-bugs
Subject:    Re: Login accounting design
From:       Peter Wemm <peter () netplex ! com ! au>
Date:       1998-03-28 15:21:34
[Download RAW message or body]

Michael Richards wrote:
> Hi. I noticed something a little weird...
> 
> [root@frodo /root]# ac -p
>         root         0.56
>         ftp          0.02
>         miker        0.22
>         jon         11.00
>         total       11.80
> [root@frodo /root]# ac -p
>         root         0.56
>         ftp          0.02
>         miker        0.22
>         jon         11.00
>         total       11.81
> [root@frodo /root]# ac -p
>         root         0.57
>         ftp          0.02
>         miker        0.22
>         jon         11.00
>         total       11.81
> 
> Someone can't add :) Well, maybe this was a 1 in a million thing where I
> happened to run the command and inbetween cpu cycles, the time changed,
> but I would think that the order of commands would be arranged such that
> the number added to the entry at the username would be the same number
> printed... Having not the time to do source digging, I am of course making
> assumptions on how the ac program was written...
> 
> -MIke

I suspect that you'll find this is a rounding issue.  I don't recall
exactly, but there are some 128 ticks per second timers, and these won't
map to an exact 0.01.  You're probably seeing the result of all
calculations being done in 1/128ths of a second and being converted to 1/
100ths at display time.

A rough example with unrounded numbers:

1:              (raw)  (rounded to 1/100)
	root:	0.562 ->  0.56
  [the rest]:  11.242 -> 11.24
               ======
       total:  11.803 -> 11.80

2:
	root:	0.564 ->  0.56
  [the rest]:  11.242 -> 11.24
               ======
       total:  11.806 -> 11.81

3:
	root:	0.566 ->  0.57
  [the rest]:  11.242 -> 11.24
               ======
       total:  11.808 -> 11.81

The raw numbers I've used would not be real 1/128 conversions, but it 
should give the idea.

Cheers,
-Peter
--
Peter Wemm <peter@netplex.com.au>   Netplex Consulting



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic