diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2000-05-04 17:26:26 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2000-05-04 17:26:26 +0000 |
commit | 680fe193ed6d28f505924aac0a850890cf7f495e (patch) | |
tree | eb97dbc2a78e154798682d38c1ec4081f9ae278f /bin/ps | |
parent | b5be3b016ab40f33f97ba8ca47147473e622e3e6 (diff) |
avoid IEEE underflow in exp(), shows up most on 68060 FPE which is precise; any math wizards want to help me clean this up?
Diffstat (limited to 'bin/ps')
-rw-r--r-- | bin/ps/print.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c index 47f2a5ceea4..5085550927e 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.14 1997/11/30 05:43:12 deraadt Exp $ */ +/* $OpenBSD: print.c,v 1.15 2000/05/04 17:26:25 deraadt Exp $ */ /* $NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -static char rcsid[] = "$OpenBSD: print.c,v 1.14 1997/11/30 05:43:12 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: print.c,v 1.15 2000/05/04 17:26:25 deraadt Exp $"; #endif #endif /* not lint */ @@ -530,6 +530,7 @@ getpcpu(k) { struct proc *p; static int failure; + double d; if (!nlistread) failure = donlist(); @@ -544,8 +545,14 @@ getpcpu(k) return (0.0); if (rawcpu) return (100.0 * fxtofl(p->p_pctcpu)); + + d = p->p_swtime * log(fxtofl(ccpu)); + if (d < -700.0) + d = 0.0; /* avoid IEEE underflow */ + else + d = exp(d); return (100.0 * fxtofl(p->p_pctcpu) / - (1.0 - exp(p->p_swtime * log(fxtofl(ccpu))))); + (1.0 - d)); } void |