Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site mcvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!mhuxn!houxm!ihnp4!zehntel!hplabs!hao!seismo!mcvax!steven From: steven@mcvax.UUCP (Steven Pemberton) Newsgroups: net.math Subject: Re: multiple-precision arithmetic Message-ID: <6213@mcvax.UUCP> Date: Mon, 3-Dec-84 08:57:05 EST Article-I.D.: mcvax.6213 Posted: Mon Dec 3 08:57:05 1984 Date-Received: Thu, 6-Dec-84 05:02:34 EST References: <163@faron.UUCP> <732@reed.UUCP> Reply-To: steven@mcvax.UUCP (Steven Pemberton) Organization: CWI, Amsterdam Lines: 38 We are producing here a new programming language, B, that includes unbounded-length rational arithmetic. The implementation we have is an interpreter rather than a compiler, but despite that it can generate the primes to 100 in about the same time as that mentioned (actually slightly faster), though factorial 100 takes longer. In comparing it with bc on Unix, it compares well, often being very much faster. The whole system, including the arithmetic, is largely machine independent - we've ported it to dozens of machines - though it is Unix dependent. We're currently producing a non-Unix version for the IBM PC. For non-commercial use it only costs the price of the media - if you're interested mail me. One lovely example of the use of unbounded arithmetic is this following B program by Lambert Meertens for producing the decimal digits of pi (after printing 80 digits of pi, a, b, c, and d are all larger than 10**200). HOW'TO PI: WRITE '3.' PUT 3, 0, 40, 4, 24, 0, 1 IN k, a, b, c, d, e, f WHILE 1=1: PUT k**2, 2*k+1, k+1 IN p, q, k PUT b, p*a+q*b, d, p*c+q*d IN a, b, c, d PUT f, floor(b/d) IN e, f WHILE e=f: WRITE e<<1 PUT 10*(a-e*c), 10*(b-f*d) IN a, b PUT floor(a/c), floor(b/d) IN e, f:> Most of it should be obvious: PUT ... IN ... is the assignment command; WRITE e<<1 writes e in width 1. Rather than let the program run to completion :-), here is a little of its output: 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899 Steven Pemberton, CWI, Amsterdam.