[issue3008] Let bin/oct/hex show floats

Mark Dickinson report at bugs.python.org
Tue Jul 15 17:57:15 CEST 2008


Mark Dickinson <dickinsm at gmail.com> added the comment:

Here's an updated patch that addresses Raymond's concerns.

> The patch looks good.  I would coded hex_from_char() using a lookup 
> into "0123456789abcdef" which uses no unpredicatable branches.  
> Likewise, I would done hex_from_char() with a case statement (limiting 
> the call to single unpredicatable branch).

Done.

> Question:  are the ("0x0p+0") and ("-0x0p+0") special cases standard?

Not entirely.  Java outputs "0x0.0p0" and "-0x0.0p0".  The C99 standard 
doesn't specify exactly how the output should look, except to say that 
the exponent should be 0.  The '+' is there for consistency.

I can change '0x0p+0' to '0x0.0p+0' if people think this looks prettier.
On consideration, this does look better to me.  Changed.

> The docs need a "new in py2.6"

Fixed.

> Coding style:  move the inner si++ to a separate line so there are no 
> side-effects and the order of execution is obvious.

Done.  (And the same with s++ in float_fromhex.)

> Question:  should the "inf" string checks be made case sensitive on 
> insensitive?  Is there a standard?

Everything I've seen, except Java, seems to like case-insensitivity.  
The C99 standard says case should be ignored, as does the IBM Decimal 
standard.  Python's float('nan') and float('inf') also currently ignore 
case.  So I think these checks should be case insensitive.

(Java insists on infinity being spelt "Infinity", and nan being spelt 
"NaN".)

Thank you for reviewing this, Raymond!

I aim to check this in when (if?) I get approval from Barry.

Added file: http://bugs.python.org/file10897/hex_float9.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3008>
_______________________________________


More information about the Python-bugs-list mailing list