Re: [Python-Dev] Float --> Integer Ratio

2008-01-24 Thread Jeffrey Yasskin
+1. Where do people want it, and what should its name be? I can implement it if you like. Another plausible output would be similar to frexp but with an integer for the mantissa instead of a float. So: A) math.frexp(3.2) == (0.80004, 2) B) integral_frexp(3.2) == (3602879701896397, -5

[Python-Dev] Float --> Integer Ratio

2008-01-24 Thread Raymond Hettinger
rational.py contains code for turning a float into an exact integer ratio. I've needed something like this in other situations as well. The output is more convenient than the mantissa/exponent pair returned by math.frexp(). I propose C-coding this function and either putting it in the math modul