On Fri, Jun 27, 2008 at 8:02 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: > Now that I've learned about the hex float format supported by C++ and > Java, I wonder if it wouldn't be better to support conversion to and > from that format and nothing else. > > E.g. > >>>> math.tohex(3.14) > '0x1.91eb851eb851fp+1' >>>> math.fromhex('0x1.91eb851eb851fp+1') > 3.1400000000000001
This would certainly be enough for me, though I think there's still some educational value in having binary output available. But that's just a matter of substituting a four-bit binary string for each hexadecimal digit (or learning to read hexadecimal as though it were binary). In fromhex, what would be done with a string that gives more hex digits than the machine precision can support? An obvious answer is just to round to the nearest float, but since part of the point of hex floats is having a way to specify a given value *exactly*, it might make more sense to raise an exception rather than changing the value by rounding it. Mark _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com