Raymond Hettinger <[EMAIL PROTECTED]> added the comment: 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 ---------- keywords: +patch Added file: http://bugs.python.org/file10664/floatdisp.diff _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3008> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com