[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Perhaps instead of changing the base lisp PRINTS numbers we
should consider changing the base lisp STORES numbers.  I
propose base i-1 (that's i=sqrt(-1)).  This has the
interesting property that you can represent all complex
integers uniquely using just the digits 0 and 1.  Thus you
could use a 36 bit word to store a complex number.

1100 = (i-1)^3+(i-1)^2 = (2+2i)+(-2i) = 2

11100 = (i-1)^4+(i-1)^3+(i-1)^2 = -2

11 = i

111011101 = 7

11000001 = -7

1000111 = 7i

11101000011 = -7i

Note that there is no kludgy "two's complement"
representation for negative numbers, they have nice finite
representations just like all the rest of the numbers.
Wouldn't it be nice to have complex integers in lisp?

Of course there are bugs:  The portion of the complex plane
covered by a 36 bit word is a rather odd shape (it IS
connected).  The representation is not easily groked by the
user (if we were all taught in grade school ....).  The
algorithms for addition and subtraction and multiplication,
although not difficult, are not supported by any hardware
that I know of.  I have been unable to devise a satisfactory
division algorithm.  We would still have to decide how to
PRINT the damn things!

Of course we would have to recompile all the FASL files in
the world (since the compiler could no longer output
instructions such as ADD or IMUL), but that is a small price
to pay for such a winning extension to the language