From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2aaba1527862ef22 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news1.google.com!newsfeed.gamma.ru!Gamma.RU!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!feeder.news-service.com!feeder1.cambrium.nl!feed.tweaknews.nl!138.195.8.3.MISMATCH!news.ecp.fr!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: Reading Float Data from a binary file into ada Date: Tue, 30 Jan 2007 17:55:11 +0100 Organization: Adalog Message-ID: References: <1170172307.292500.256090@m58g2000cwm.googlegroups.com> NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1170176490 21586 195.25.228.57 (30 Jan 2007 17:01:30 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Tue, 30 Jan 2007 17:01:30 +0000 (UTC) User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) In-Reply-To: <1170172307.292500.256090@m58g2000cwm.googlegroups.com> Xref: g2news2.google.com comp.lang.ada:8720 Date: 2007-01-30T17:55:11+01:00 List-Id: frikk a �crit : > 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). Hmm... This looks like a fixed point representation, not a floating point one. > 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@adalog.fr) Visit Adalog's web site at http://www.adalog.fr