Re: Reading Float Data from a binary file into ada
- From: Jean-Pierre Rosen <rosen@xxxxxxxxx>
- Date: Tue, 30 Jan 2007 17:55:11 +0100
frikk a écrit :
Hello everyone! I am having a problem that I would love some help with.Hmm... This looks like a fixed point representation, not a floating point one.
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?In general, Unchecked_Conversion is your friend when you need two different views, at differing levels of abstraction, of the same data.
Basically I need to be able to read in the binary data byte by byte but store it into a 32 bit Float.However, if you do an unchecked_conversion to Float, it will certainly not work, because your data don't look at all like floats!
--
---------------------------------------------------------
J-P. Rosen (rosen@xxxxxxxxx)
Visit Adalog's web site at http://www.adalog.fr
.
- Follow-Ups:
- Re: Reading Float Data from a binary file into ada
- From: Ali Bendriss
- Re: Reading Float Data from a binary file into ada
- 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: Reading Float Data from a binary file into ada
- Next by Date: Re: Reading Float Data from a binary file into ada
- Previous by thread: Re: Reading Float Data from a binary file into ada
- Next by thread: Re: Reading Float Data from a binary file into ada
- Index(es):
Relevant Pages
|