comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: How to byte swap an IEEE Float?
Date: Thu, 30 Jun 2005 14:14:35 -0500
Date: 2005-06-30T14:14:35-05:00	[thread overview]
Message-ID: <18mdnTAI9YB93lnfRVn-3g@megapath.net> (raw)
In-Reply-To: 1119991404.697144.17980@g14g2000cwa.googlegroups.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1162 bytes --]

"Bj�rn" <ssh9614@hotmail.com> wrote in message
news:1119991404.697144.17980@g14g2000cwa.googlegroups.com...
...
> All the data in the file are of 32 bits float so that should be ok.
> The target for the values is at the moment x86 (although I do expect it
> to work on PowerPC as well so I check System.Default_Bit_Order before
> doing any byte swapping). My dirty workaround for the moment was to
> read the data as a string. I was merly wondering which is the
> normal/"best" way to deal with this, since I expect it to be a
> fairly common task. A packed byte array does however seem like a much
> better idea than handling it as a string.

I'd suggest using an array of stream elements for that (presuming that
they're the right size, they would be on almost all machines). That's
especially useful if you're reading the type as a stream in the first place,
because it would let you skip a copy.

If you absolutely have to have portability to any possible machine, then
you'd need to use your own type. But such a machine (such as the 36 bit
Unisys U2200) would probably have problems with 32-bit float values anyway.

                         Randy.






  parent reply	other threads:[~2005-06-30 19:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-28 13:53 How to byte swap an IEEE Float? Björn
2005-06-28 15:06 ` Marius Amado Alves
2005-06-28 15:55   ` Simon Wright
2005-06-28 16:59     ` Marius Amado Alves
2005-06-28 20:43       ` Björn
2005-06-29  0:13         ` Marius Amado Alves
2005-06-30 19:14         ` Randy Brukardt [this message]
2005-06-28 16:05 ` Martin Dowie
2005-06-28 23:35 ` Stephen Leake
2005-06-29 10:00   ` Björn
2005-06-30  0:52     ` Stephen Leake
2005-07-01  4:51       ` Simon Wright
2005-06-29 20:10 ` Damien
2005-06-30 11:35   ` Peter Hermann
2005-06-30 22:26     ` Damien
2005-07-01  7:37       ` Peter Hermann
replies disabled

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