From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8200c5d9633351c4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!g14g2000cwa.googlegroups.com!not-for-mail From: "=?iso-8859-1?B?Qmr2cm4=?=" Newsgroups: comp.lang.ada Subject: Re: How to byte swap an IEEE Float? Date: 28 Jun 2005 13:43:24 -0700 Organization: http://groups.google.com Message-ID: <1119991404.697144.17980@g14g2000cwa.googlegroups.com> References: <1119966822.201891.303810@g49g2000cwa.googlegroups.com> NNTP-Posting-Host: 213.114.86.167 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1119991409 14724 127.0.0.1 (28 Jun 2005 20:43:29 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 28 Jun 2005 20:43:29 +0000 (UTC) User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: g14g2000cwa.googlegroups.com; posting-host=213.114.86.167; posting-account=XtH-7w0AAAD9fnmY345GWHA6uyNTbG5H Xref: g2news1.google.com comp.lang.ada:11706 Date: 2005-06-28T13:43:24-07:00 List-Id: > Sure. You know, I meant representation =3D bits and bytes, implying same > length. It seems the OP already has the float type (IEEE_Float_32), > 32-bit =3D 4-byte long, and the data are floats of this length, only > different in byte order. > > OP, if the data are of a different length, then you have to unchecked > convert first to a float type of that length, and then normal convert > to the final type (risking Constraint_Error). 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. Regards Bj=F6rn