En Tue, 02 Oct 2007 01:59:35 -0300, [EMAIL PROTECTED]  
<[EMAIL PROTECTED]> escribi�:

> How does gmpy make the conversion from float to rational?

Well, you know, these days valuable software usually comes with something  
people call "documentation". Incomprehensible documents in strange formats  
talking about esoteric stuff that nobody is able to read (as if someone  
wanted to actually read them!).
Hidden in the land of Mordor where the shadows lie, there is an ancient  
scroll -a long time forgotten by mankind- where you can read terrible  
things like this:

"If an mpf or float argument is passed, the
mpq is built from it with an 'optimal' approach based on a
Stern-Brocot tree." <http://gmpy.googlecode.com/svn/trunk/doc/gmpydoc.txt>

On the motivation for doing such evil things, you can read the explanation  
given centuries ago by its creator, by then the High Wizard Alessandro:

"[The algorithm tries] to convert floats to rationals
giving the smallest denominator compatible with the hypothesis that
the float is precise to N bits [...] usually DBL_MANT_BITS [...] normally  
53 today"

<http://mail.python.org/pipermail/python-list/2002-October/166974.html>

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to