comp.lang.ada
 help / color / mirror / Atom feed
From: pontius@twonky.btv.ibm.com (Dale Pontius)
Subject: Byte sex
Date: 1996/03/28
Date: 1996-03-28T00:00:00+00:00	[thread overview]
Message-ID: <4jeuej$mbq@twonky.btv.ibm.com> (raw)


I've this thing called a 'binary rawspice' file, which has a text
header and a bunch of floating point data. In some variations of
the basic format, there may be more text after the binary data,
and more binary data following that.

At the moment, this file is likely written by an application on
a big-endian machine. (RS/6000 running AIX) I'd like to be able
to read it on both big-endian and little-endian (x86 running OS/2)
machines.

I understand that Streams are the way to go, and I have some code
already running to handle this. In a few more iterations, I'm
about to stumble over reading the floating point data, stored as
either 4-byte or 8-byte REALs.

I suspect I'm going to have to handle the byte-sex issue, and
re-order the bytes as I read them in, in order to get a float
written by big-endian to look civil to a little-endian program.
In Modula-2 I would have declared a variant record, stuffing bytes
in in one order, and pulling the REAL out. The Ada equivalent of
the variant record looks 'safe', (tagged) so that I can't easily
do the same trick. Does Ada include any other facility to help
me here, or do I need to delve into 'Unchecked Conversions'?
(Or is there some 'standard' byte sequence for writing IEEE
 floating point numbers, so that I don't need to worry about it
 at all?)

Thanks,
Dale Pontius
(NOT speaking for IBM)




             reply	other threads:[~1996-03-28  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-28  0:00 Dale Pontius [this message]
1996-03-28  0:00 ` Byte sex Ted Dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox