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,FREEMAIL_FROM autolearn=ham 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!news2.google.com!news.germany.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!news.highwinds-media.com!xara.net!gxn.net!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Reading Float Data from a binary file into ada Date: Thu, 01 Feb 2007 21:11:26 +0000 Organization: Pushface Message-ID: References: <1170172307.292500.256090@m58g2000cwm.googlegroups.com> <45bf9b8b$0$22527$39db0f71@news.song.fi> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1170364285 8083 62.49.19.209 (1 Feb 2007 21:11:25 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Thu, 1 Feb 2007 21:11:25 +0000 (UTC) Cancel-Lock: sha1:WaSHSkM2oWVqFvFw6RaQFUZm+WY= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) Xref: g2news2.google.com comp.lang.ada:8825 Date: 2007-02-01T21:11:26+00:00 List-Id: Niklas Holsti writes: > - Use the functions Shift_Left or Shift_Right together with > the "or" operator (all from Interfaces) to assemble 4 octets > (Unsigned_8 values) into one 32-bit value of type > Interfaces.Unsigned_32. You may have to experiment to > get the octets in the right order. > > - Then use Unchecked_Conversion to go from Unsigned_32 to Float. IF the VB view splits on octet boundaries, it can be easier to read into an array of 4 octets (32 bits read), do the unchecked conversion from array-of-4-octets to float with reordering; something like v : four_byte_array; function convert is new ada.unchecked_conversion (four_byte_array, float); read (v); result := convert ((1 => v (4), 2 => v (3), 3 => v (2); 4 => v (1))); If not, why not read into unsigned_32 in the first place?