[comp.lang.c] fractional bases

jrk@s1.sys.uea.ac.uk (Richard Kennaway CMP RA) (10/19/88)

(Maybe this should move to comp.theory...)

In article <821@accelerator>, rob@raksha.eng.ohio-state.edu (Rob Carriere) writes:
> In article <14014@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
> > [...]
> >I must admit that inventing a notation for writing fractional digits
> >is beyond me: [...]
> 
> That's where you lost me.  In base b we have b different digits, so in
> base e we have .... well, eh, we should have... that is to say, ...

The base and the set of available digits are not necessarily related.
In conventional base 2, base 10, base n (an integer), etc. one normally uses
digits 0..1, 0..9, in general 0..n-1.  But this is just convention.

In general, you have a base b, and a set of "digits" D.
b and all the members of D are arbitrary
numbers (in whatever number system you are using - I'll stick to reals
here, but it applies to complex numbers, quaternions, whatever).

A representation of a number n in such a system is an equality:

	                  i
	n =    SUM   d .(b )
	     i in I   i

where I is some subset of the integers and each d/i is a member of D.

Depending on the choice of b or D, it may be that some numbers have no
representation in the base, or may have more than one.  For example, ordinary
decimals use b=10 and D={0,1,2,3,4,5,6,7,8,9}.  Negative reals have no
representation; and some reals have two (e.g. 1 = 0.9999...).  One
normally gets negative numbers by the kludge of prefixing a minus to the
whole thing; alternatively one may use b = -10, or b = 10 and
D = {-4,-3,-2,-1,0,1,2,3,4,5}.  Better still is b = 10, D =
{-5,-4,-3,-2,-1,0,1,2,3,4,5}, as with this representation it is possible
to compute with real numbers in a mathematically more respectable way
than the "floating point" numbers usually used in programming languages.

b = -10.sqrt(-1), D = {-5..5} gives you a similar representation of complex
numbers.

Taking b = (-1-sqrt(5))/2 = -1.618...(decimal) and D = {0,1} is fun.
Try programming multiplication of such representations in a language
with lazy lists.
-- 
Richard Kennaway
School of Information Systems, University of East Anglia, Norwich, U.K.
uucp:	...mcvax!ukc!uea-sys!jrk	Janet:	kennaway@uk.ac.uea.sys