Strange rounding problem

Steven Taschuk staschuk at telusplanet.net
Sat Mar 15 21:39:15 CET 2003


Quoth Jp Calderone:
  [...]
>   I believe the rule is generally expressable - a base can exactly represent
> fractions which can be expressed as sums of the inverses of powers of
> factors of the base.  [...]

... and only those fractions.

The proof is not difficult.  A value x with a terminating
expression
	x = 0 . a_1 a_2 a_3 ... a_n
in some base b obviously has the property that
	x * b^n is an integer
and conversely, any value x with this property has a terminating
expression.  So a fraction p/q has a terminating expression if and
only if q divides some power of b, that is, if and only if all of
q's prime factors are also prime factors of b.  Your description
of the rule follows quickly.

  [...]
>   15 is the next best base after 10, and 30 after that.  Of course, no base
> can exactly represent any fraction, and this doesn't even take into
> consideration bases which are, themselves, fractional ;)

6 and 14 seem just as good as 10 and 15 to me, by this criterion.

-- 
Steven Taschuk             "The world will end if you get this wrong."
staschuk at telusplanet.net     -- "Typesetting Mathematics -- User's Guide",
                                 Brian Kernighan and Lorrinda Cherry





More information about the Python-list mailing list