This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients alexandre.vassalotti, belopolsky, pitrou, rhettinger, terry.reedy
Date 2008-06-20.01:25:56
SpamBayes Score 0.13437614
Marked as misclassified No
Message-id <1213925165.47.0.985378592439.issue3008@psf.upfronthosting.co.za>
In-reply-to
Content
To address the ideas brought-up so far, here's a new version that can 
work with eval.  The same appoach extends to oct and hex as well:

def newbin(f):
    """
        >>> newbin(3.125)
        '0b11001 * 2.0 ** -3'
    """
    n, d = f.as_integer_ratio()
    s = '%s * 2.0 ** %d' % (bin(n), -math.log(d, 2.0))
    return s
History
Date User Action Args
2008-06-20 01:26:06rhettingersetspambayes_score: 0.134376 -> 0.13437614
recipients: + rhettinger, terry.reedy, belopolsky, pitrou, alexandre.vassalotti
2008-06-20 01:26:05rhettingersetspambayes_score: 0.134376 -> 0.134376
messageid: <1213925165.47.0.985378592439.issue3008@psf.upfronthosting.co.za>
2008-06-20 01:26:04rhettingerlinkissue3008 messages
2008-06-20 01:26:03rhettingercreate