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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2aaba1527862ef22 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!tiscali!newsfeed1.ip.tiscali.net!proxad.net!proxad.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Reading Float Data from a binary file into ada Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1170172307.292500.256090@m58g2000cwm.googlegroups.com> Date: Tue, 30 Jan 2007 17:37:35 +0100 Message-ID: <1485fj2r08vic$.9nadz1lhggpw.dlg@40tude.net> NNTP-Posting-Date: 30 Jan 2007 17:37:35 CET NNTP-Posting-Host: e9a4189f.newsspool2.arcor-online.net X-Trace: DXC=57oT\BH3Ybhk23ATak28iDNcfSJ;bb[eFCTGGVUmh?dLK[5LiR>kgbH8lVUeFZd]i X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:8719 Date: 2007-01-30T17:37:35+01:00 List-Id: On 30 Jan 2007 07:51:47 -0800, frikk wrote: > 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). 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? Only if you could be sure about the format. But there is a portable way to do such things. You read 4 octets. From them (you should know the endianness of the machine that wrote the file) take the sign bit, take the biased exponent, take the mantissa (as an integer). The mantissa will probably have a hidden bit. (I don't know what for format Basic uses.) After that use T'Compose to produce the number of floating-point T. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de