Re: Reading Float Data from a binary file into ada



"frikk" <frikker@xxxxxxxxx> writes:

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?

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,
which is IEEE on many machines. Of course, neither language standard
requires any particular representation, but it's usually safe to trust
that C float and Ada Float are represented the same way on the same
machine.

The VB format you mentioned doesn't sound like IEEE float, but anyway,
if you want to write an Ada algorithm that mimics the C one, you should
use Unchecked_Conversion to do the "cast" from array-of-4-bytes to
Float, if that's what it does.

- Bob
.



Relevant Pages

  • 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: Reading Float Data from a binary file into ada
    ... but store it into a 32 bit Float. ... We are using simulink and calling ada through s-functions. ... a round about syntax to help me get started in setting up the memory ...
    (comp.lang.ada)
  • 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: 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)
  • Re: Reading Float Data from a binary file into ada
    ... 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). ... There is a C counterpart to this that makes use of a 'union' to grab the data 1 byte 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? ...
    (comp.lang.ada)