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,d54d00ef5d8d6349 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!69.28.186.77.MISMATCH!hwmnpeer03.lga!hwmnpeer01.lga!news.highwinds-media.com!news-server.columbus.rr.com!cyclone2.kc.rr.com!news2.kc.rr.com!tornado.socal.rr.com.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Convert Unsigned_32 to Ieee_Float_32 References: <1161883988.538024.321940@b28g2000cwb.googlegroups.com> From: Keith Thompson Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:Ial/au9jKIKX6ZUhir38HjF1htE= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 26 Oct 2006 22:03:05 GMT NNTP-Posting-Host: 75.80.183.54 X-Complaints-To: abuse@rr.com X-Trace: tornado.socal.rr.com 1161900185 75.80.183.54 (Thu, 26 Oct 2006 15:03:05 PDT) NNTP-Posting-Date: Thu, 26 Oct 2006 15:03:05 PDT Organization: Road Runner High Speed Online http://www.rr.com Xref: g2news2.google.com comp.lang.ada:7224 Date: 2006-10-26T22:03:05+00:00 List-Id: "Richard Charts" writes: > Well I ran into a fun error today. > > Apparently on Green Hills, > Interfaces.Unsigned_32( [Some Item of Type Interfaces.Ieee_Float_32]) > causes a compiler error. > C:\DOCUME~1\...\LOCALS~1\Temp\gh_lk1.s 2212: lwz f29,112(sp) > C:\DOCUME~1\...\LOCALS~1\Temp\gh_lk1.s 2212: ----^- > C:\DOCUME~1\...\LOCALS~1\Temp\gh_lk1.s 2212: expected register > > So just to get my project compiling, I substituted: > Interfaces.Unsigned_32'Value(Interfaces.Ieee_Float_32'Image(Real_Obj.Resolution)) > > But that's a rather expensive convertion. > Can anyone recommend a better way until, I find a way around the above > error? That's not going to work anyway (though, as you say, it will compile). The string returned by Ieee_Float_32'Image isn't going to be a valid integer literal, so Unsigned_32'Value will raise Constraint_Error. The first thing I'd try is to do the conversion via some other intermediate type; maybe the bug doesn't happen to affect Float_64, for example. If that fails, you could write your own brute-force conversion function. If you just want to get it working quickly, without worrying about efficiency, you could instantiate Float_IO for tpe IEEE_Float_32, then use Put with Fore => 0, Aft => 0, Exp => 0 to write it to a string, delete or otherwise ignore the trailing ".0" (or ".1", or whatever), and apply Unsigned_32'Value to that. -- Keith Thompson (The_Other_Keith) kst-u@mib.org San Diego Supercomputer Center <*> We must do something. This is something. Therefore, we must do this.