Infinite-precision arithmetic

Dar Scott dsc at swcp.com
Tue May 24 23:50:39 EDT 2005


On May 24, 2005, at 9:07 PM, John Vokey wrote:

> I have always found binary coded decimal (BCD) the simplest for this 
> purpose, as it is directly extensible to any length, with only a few 
> lines of code.  Please see any (low-level; i.e., machine-code) book on 
> arithmetic algorithms.  They may not teach BCD anymore, but back in 
> the day... (i.e., Earth still cooling, ...).

BCD is nice for simple conversion to decimal, especially if you have no 
divide.

In one sense, one of the methods the Cubist mentioned is related if we 
stretch our imagination.  Just as BCD maps one digit to 4 bits binary, 
7 digits can be mapped to 8-bytes floating point.  The latter makes it 
handy for multiplication since you can multiply 7 digits by seven 
digits and not lose anything.  Even if the Cubist represents a number 
as a series of doubles, he can convert to a decimal numeral quickly 
without division.

One of the superstitions that came out of the time the Earth was still 
cooling was that decimal arithmetic required some sort of decimal 
representation.  Not so.  You just need a decimal point.  It is a 
subtle distinction, but one that can open doors of representation.

Dar

-- 
**********************************************
     DSC (Dar Scott Consulting & Dar's Lab)
     http://www.swcp.com/dsc/
     Programming and software
**********************************************



More information about the use-livecode mailing list