[Python-Dev] float.decode()?

Neil Schemenauer nas@python.ca
Mon, 15 Apr 2002 14:56:48 -0700

Common Lisp has a function called decode-float:

    (decode-float float) => significand, exponent, sign

    computes three values that characterize float. The first value is of
    the same type as float and represents the significand. The second
    value represents the exponent to which the radix (notated in this
    description by b) must be raised to obtain the value that, when
    multiplied with the first result, produces the absolute value of
    float. If float is zero, any integer value may be returned, provided
    that the identity shown for scale-float holds. The third value is of
    the same type as float and is 1.0 if float is greater than or equal
    to zero or -1.0 otherwise.

How hard would it be to write a method like this for Python floats?  I
think it could go a long way in helping people understand how floating
point works.