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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable 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!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!feeder.news-service.com!proxad.net!cleanfeed1-b.proxad.net!nnrp17-2.free.fr!not-for-mail Return-Path: From: Ali Bendriss Organization: The Dementia Research Centre To: comp.lang.ada@ada-france.org Subject: Re: Reading Float Data from a binary file into ada Date: Tue, 30 Jan 2007 17:35:30 +0000 User-Agent: KMail/1.9.4 References: <1170172307.292500.256090@m58g2000cwm.googlegroups.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: ClamAV using ClamSMTP X-UCL-MailScanner-Information: Please contact the UCL Helpdesk, helpdesk@ucl.ac.uk for more information X-UCL-MailScanner: Found to be clean X-UCL-MailScanner-From: ali.bendriss@drc.ion.ucl.ac.uk X-Virus-Scanned: amavisd-new at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.9rc1 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.ada Message-ID: X-Leafnode-NNTP-Posting-Host: 88.191.17.134 NNTP-Posting-Date: 30 Jan 2007 18:40:02 MET NNTP-Posting-Host: 88.191.14.223 X-Trace: 1170178802 news-1.free.fr 10798 88.191.14.223:49421 X-Complaints-To: abuse@proxad.net Xref: g2news2.google.com comp.lang.ada:8721 Date: 2007-01-30T18:40:02+01:00 On Tuesday 30 January 2007 16:55, Jean-Pierre Rosen wrote: > frikk a =E9crit : > > 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. > There is the same kind of representation in the tiff format, The "type RATIONAL" two LONGs : the first represent the numerator of the=20 fraction, the second the denominator. > > 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. > I remember doing some Unchecked_Conversion to read a proprietary tiff file= =20 some time ago. But only to find the LONGs and then after I was just doing a= =20 simple division to get the result.=20 > > Basically I need to be able to read in the binary data byte by byte > > but store it into a 32 bit Float. > It may be helpfull to know some value in advance like a magic number. > However, if you do an unchecked_conversion to Float, it will certainly > not work, because your data don't look at all like floats! =2D-=20 Ali=20