Newsgroups: comp.arch Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: COBOL Decimal Arithmetic Message-ID: <1989Sep24.003602.7988@utzoo.uucp> Organization: U of Toronto Zoology References: <943@rd1632.Dayton.NCR.COM> Date: Sun, 24 Sep 89 00:36:02 GMT In article <943@rd1632.Dayton.NCR.COM> otto@rd1632.UUCP (Jerome A. Otto) writes: >(2) Convert to binary (using hardware instructions if > available), add binary, convert from binary (using > hardware if available) > >Very seldom, if ever, is (2) fastest due to the problem of >converting from binary to decimal. This conversion requires >N divides or N+1 multiplies (N = number of digits)... Nonsense. The multiplies and divides are done at compile time; the conversion is done with table lookup or the decision-tree equivalent. Even the simplest approach requires roughly 4N comparisons, a bit of data movement, and no multiplies or divides at all. Byte-at-a-time table lookup reduces this nearly to zero. Agreed, however, that playing tricks with the binary adder is a viable alternative if very little arithmetic is being done. -- "Where is D.D. Harriman now, | Henry Spencer at U of Toronto Zoology when we really *need* him?" | uunet!attcan!utzoo!henry henry@zoo.toronto.edu