Re: Reading Float Data from a binary file into ada



On Jan 30, 1:04 pm, "frikk" <frik...@xxxxxxxxx> wrote:
On Jan 30, 12:56 pm, "Jeffrey R. Carter" <jrcar...@xxxxxxx> wrote:

frikk wrote:

Basically I need to be able to read in the binary data byte by byte
but store it into a 32 bit Float. The C union example above uses the
same memory address for the Float as it does for the size 4 char
array. I don't even know if the VB dump will correspond with the way
ada handles floats or not, but I'll worry about that later.

Any reason you can't call this C function from Ada?

--
Jeff Carter
"I soiled my armor, I was so scared."
Monty Python & the Holy Grail
71

Thank you for the responses so far.

We are using simulink and calling ada through s-functions. If we use
C, we'd have to get the data back to the matlab workspace, then pass
it into an ada module. It is prefered to keep all of the data inside
the ada modules without coming back to the workspace.

I've been working with ada for awhile, but I'm still not very good at
the syntaxes of more complicated data management commands. How does
ada store its floating point data? Is it stored like an ieee standard?

And yes - it appears that the data dumped is not actually a float but
fixed point. This is how VB apparently handles 'Float' data types.

If I had data in a binary file, even disregarding the fractional
piece, how could I get this into an ada variable? If I could even get
a round about syntax to help me get started in setting up the memory
locations and such that would be helpful. Its hard to find specific
examples sometimes.

Thanks!
Blaine

Actually - now that I look at it Visual Basic is using a 'Single'
type, not 'Float'. This may make more sense now.

.



Relevant Pages

  • Re: Ada array vs C pointer (call by reference)
    ... I have a C library function which takes a float * as a parameter. ... where data is an array of float which size is determined by pwmCount. ... In Ada, I have: ... I've never heard of an Ada compiler that doesn't, ...
    (comp.lang.ada)
  • Re: Reading Float Data from a binary file into ada
    ... but store it into a 32 bit Float. ... Any reason you can't call this C function from Ada? ... a round about syntax to help me get started in setting up the memory ...
    (comp.lang.ada)
  • Re: memory management in Ada: tedious without GC?
    ... I'd like to point out that in Ada you have less need for dynamically allocated memory. ... type Vector is of Float; ... In C/C++ you'll need to dynamically allocate V on the heap, and then worry about freeing this memory. ...
    (comp.lang.ada)
  • Re: Reading Float Data from a binary file into ada
    ... Is it stored like an ieee standard? ... Ada and C are the same in this regard -- Ada and C compilers will ... typically store Floats in the way the hardware normally stores them, ... that C float and Ada Float are represented the same way on the same ...
    (comp.lang.ada)
  • Re: Ada array vs C pointer (call by reference)
    ... Ada type "Float", to ensure that you're using the same kind of float ... that the C routine expects. ... Ada can't guarantee it directly. ...
    (comp.lang.ada)