IBM integer and double formats

Mark Dickinson dickinsm at gmail.com
Mon Nov 10 15:16:48 EST 2008


On Nov 10, 7:20 pm, "john.goodleaf" <john.goodl... at gmail.com> wrote:
> does anyone know of an already-done means of writing
> integers and floats out to their IBM mainframe equivalents?
>

I don't know of anything in Python that does this.  There was
a thread a while ago that may be relevant:

http://mail.python.org/pipermail/python-list/2004-March/255361.html

and Googling 'IBM VAX double conversion' produces some tools that
convert between IEEE, IBM and VAX double formats.  I'm not quite
sure what you're after here:  I assume that you're working on
some type of modern non-IBM (and therefore presumably IEEE
754-based) hardware, and you want to be able to convert IEEE
doubles to IBM style doubles.  Is that right?

It shouldn't be too difficult to write routines, making use
of math.ldexp and math.frexp.  The fun part would be deciding
how to handle NaNs and infinities when encoding to IBM format,
and how to handle out-of-range floats coming back (if I recall
correctly, the IBM format allows a wider range of exponents
than IEEE).

Mark



More information about the Python-list mailing list