[Python-Dev] float.decode()?

Alex Martelli aleax@aleax.it
Tue, 16 Apr 2002 00:05:39 +0200

On Monday 15 April 2002 23:56, Neil Schemenauer wrote:
> Common Lisp has a function called decode-float:
>     (decode-float float) => significand, exponent, sign
> How hard would it be to write a method like this for Python floats?  I

You mean something like:

import math
def decode_float(f):
    m, e = math.frexp(f)
    mabs = math.fabs(m)
    return mabs, e, mabs and (m/mabs)

or am I missing something?