Path: utzoo!attcan!uunet!olivea!apple!mips!hal!mark From: mark@mips.COM (Mark G. Johnson) Newsgroups: comp.benchmarks Subject: (Useless) X (Meaningless) {digits of PI} Message-ID: <45469@mips.mips.COM> Date: 1 Feb 91 22:50:24 GMT Sender: news@mips.COM Reply-To: mark@mips.COM (Mark G. Johnson) Lines: 60 Here is an article that contains the cross-product of two allegedly useless pursuits: (1) promulgating small CPU benchmarks; (2) calculating digits of PI. The C code posted by jroth@allvax.dec.com (Jim Roth) on 25 Jun 90 14:10:59 GMT was tried on a couple of machines. This program calculates the first 1000 decimal digits of PI. Here are the meager benchmark measurements made to date (/bin/time): Sun SPARCStation 1+ 9.5 real 9.5 user 0.0 sys Sun SPARCStation 2 29.4 real 29.3 user 0.0 sys <*** huh? MIPS Magnum workstation 3.0 real 2.8 user 0.0 sys Note the very anomalous result on SS-II; I tried the code on 3 different machines and kept getting the same answer. Replication/refutation of this result would be much appreciated. Speed of the IBM-POWER RISC wizzies on (computing digits of PI) would be interesting to know, too; unfortunately I don't have one close to hand. C code follows: ------------------------------------------------------------------------------ /* Message-ID: <1902@ryn.esg.dec.com> */ /* Date: 25 Jun 90 14:10:59 GMT */ /* 1000 digits of PI */ /* 'Spigot' algorithm origionally due to Stanly Rabinowitz */ #include #include main() { long d = 4, r = 10000, n = 251, m = 3.322*n*d; long i, j, k, q; static long a[3340]; for (i = 0; i <= m; i++) a[i] = 2; a[m] = 4; for (i = 1; i <= n; i++) { q = 0; for (k = m; k > 0; k--) { a[k] = a[k]*r+q; q = a[k]/(2*k+1); a[k] -= (2*k+1)*q; q *= k; } a[0] = a[0]*r+q; q = a[0]/r; a[0] -= q*r; printf("%04d%s", q, i & 7 ? " " : "\n"); } } -- -- Mark Johnson MIPS Computer Systems, 930 E. Arques M/S 2-02, Sunnyvale, CA 94086 (408) 524-8308 mark@mips.com {or ...!decwrl!mips!mark}