Re: Reading Float Data from a binary file into ada
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Tue, 30 Jan 2007 17:37:35 +0100
On 30 Jan 2007 07:51:47 -0800, frikk wrote:
Hello everyone! I am having a problem that I would love some help
with.
Essentially I was given a Visual Basic program that dumps a binary
configuration file with all of the variables in a set. The variables
are each 32 bit floats, with the first 16 bits being the integer part
and the second 16 bits being a representation of the fraction (I'm not
sure if this is stanard - but its just how VB dumps the data). The
binary dump is basically a copy of the way VB stores the data in
memory. I need to be able to use this data in ada. There is a C
counterpart to this that makes use of a 'union' to grab the data 1
byte (8 bits) at a time, put them into a char array of size 4, then
use a 32 bit float to reference the data. Is there somehow I can do
this in ada as well?
Only if you could be sure about the format.
But there is a portable way to do such things. You read 4 octets. From them
(you should know the endianness of the machine that wrote the file) take
the sign bit, take the biased exponent, take the mantissa (as an integer).
The mantissa will probably have a hidden bit. (I don't know what for format
Basic uses.) After that use T'Compose to produce the number of
floating-point T.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.
- References:
- Reading Float Data from a binary file into ada
- From: frikk
- Reading Float Data from a binary file into ada
- Prev by Date: Re: How come Ada isn't more popular?
- Next by Date: Re: Reading Float Data from a binary file into ada
- Previous by thread: Reading Float Data from a binary file into ada
- Next by thread: Re: Reading Float Data from a binary file into ada
- Index(es):