Re: How to byte swap an IEEE Float?
- From: Marius Amado Alves <amado.alves@xxxxxxxxxx>
- Date: Tue, 28 Jun 2005 16:06:46 +0100
On 28 Jun 2005, at 14:53, Björn wrote:
I need to read some float values from file that have been written in big-endian byte order from a c-program. The simple swapping procedure that I have just interchanges the byte order of type IEEE_Float_32 to get little-endian. The problem is that for some values (eg. 33.229000) it is a "NaN" when doing IEEE_Float_32'Read and I get a constraint error (invalid data) from stream_io when the value is read. How do I get around this?
Simple. Setup an array of bytes with the same representation of the float type (use representation clauses and pragma Pack). Read the array of bytes. Swap the bytes. Convert to the float type (use unchecked conversion).
.
- Follow-Ups:
- Re: How to byte swap an IEEE Float?
- From: Simon Wright
- Re: How to byte swap an IEEE Float?
- References:
- How to byte swap an IEEE Float?
- From: Björn
- How to byte swap an IEEE Float?
- Prev by Date: How to byte swap an IEEE Float?
- Next by Date: Re: How to byte swap an IEEE Float?
- Previous by thread: How to byte swap an IEEE Float?
- Next by thread: Re: How to byte swap an IEEE Float?
- Index(es):
Relevant Pages
|