Dick Moores wrote: > Dan Bishop wrote at 04:07 4/13/2005: ... > >For a floating-point number x, the representation with d "decimal" > >places count be found by taking the representation of int(round(x * > >radix ** d)) and inserting a "." d places from the right. > > But I'm sorry, but I can't follow you. I do have the first 10000 or so > places of pi base 10 (<http://mathwithmrherte.com/pi_digits.htm>), but > could you show me what to do with, say, just 3.14159?
First, decide how many "decimal" places to use for the conversion. Five decimal digits is equivalent to 5*log(10)/log(12) = 4.63 base-12 digits, so use 4 digits. Next, multiply by 12**4, obtaining the value 65144.01024, and round to the nearest integer, 65144. Convert this to base 12, obtaining 31848. But this is 12**4 times the number we really want, so divide this by 12**4 (i.e., shift the radix point left 4 places), for a final result of 3.1848. -- http://mail.python.org/mailman/listinfo/python-list
