[Python-Dev] [Python-checkins] r64424 - in python/trunk:Include/object.h Lib/test/test_sys.py Misc/NEWSObjects/intobject.c Objects/longobject.c Objects/typeobject.cPython/bltinmodule.c

Mark Dickinson dickinsm at gmail.com
Thu Jun 26 23:26:42 CEST 2008


On Thu, Jun 26, 2008 at 9:55 PM, Mark Dickinson <dickinsm at gmail.com> wrote:
>
> It's disadvantage from Python's point of view is that some features are IEEE 754

Aargh!  I can't believe I wrote that.  Its.  Its.  Its.  Anyway;  some
more detail:

Both C99 and Java 1.5/1.6 support hex floating-point literals;  both
in exactly the
same format, as far as I can tell.  Here are the relevant productions
from the Java
grammar:

HexDigit: one of
        0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F

HexNumeral:
        0 x HexDigits
        0 X HexDigits

HexDigits:
        HexDigit
        HexDigit HexDigits

HexadecimalFloatingPointLiteral:
        HexSignificand BinaryExponent FloatTypeSuffix_opt

HexSignificand:
        HexNumeral
        HexNumeral .
        0x HexDigits_opt . HexDigits
        0X HexDigits_opt . HexDigits

BinaryExponent:
        BinaryExponentIndicator SignedInteger

BinaryExponentIndicator:one of
        p P

Java's 'Double' class has a 'toHexString' method that
outputs a valid hex floating point string, and the Double()
constructor also accepts such strings.

C99 also appears to have full support for input/output
of hex floats; e.g. using strtod and printf('%a', ...).

Not sure how helpful this is.

Mark


More information about the Python-Dev mailing list