python rounding problem.

Grant Edwards grante at visi.com
Mon May 8 23:35:40 CEST 2006


On 2006-05-08, Thomas Bartkus <thomasbartkus at comcast.net> wrote:

>> Or you can write  0.1
>>                      3
>>
>> :)
>
> Ahhh!
>
> But if I need to store the value 1/10 (decimal!), what kind of
> a precision pickle will I then find myself while working in
> base 3?

Then we're right back where we started.  No matter what base
you choose, any fixed length floating-point representation can
only represent 0% of all rational numbers.

So, clearly what we need are floating point objects with
configurable bases -- bases that automatically adjust to
maintain exact representation of calculation results.  Which
probably exactly the same as just storing rational numbers as
numerator,denominator tuples as you suggest.

> How much better for precision if we just learn our fractions
> and stick to storing integer numerators alongside integer
> denominators in big 128 bit double registers ?
>
> Even the Nenets might become more computationally precise by
> such means ;-) And how does a human culture come to decide on
> base 9 arithmetic anyway?

I've no clue, whatsoever.  I just stumbled across that factoid
when I used Wikipedia to look up which civilizations used
base-60.  For some reason I can never remember whether it was
one of the mesoamerican ones or one of the mesopotamian ones.

> Even base 60 makes more sense if you like it when a lot of
> divisions come out nice and even.

Did they actually have 60 unique number symbols and use
place-weighting in a manner similar to the arabic/indian system
we use?

> Do the Nenets amputate the left pinky as a rite of adulthood
> ;-)

Nah, winters up there are so friggin' cold that nobody ever has
more than nine digits by the time they reach adulthood.

-- 
Grant Edwards                   grante             Yow!  Hello. Just walk
                                  at               along and try NOT to think
                               visi.com            about your INTESTINES being
                                                   almost FORTY YARDS LONG!!



More information about the Python-list mailing list