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: a07f3367d7,6fabd104d18f3943 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.albasani.net!not-for-mail From: Dirk Herrmann Newsgroups: comp.lang.ada Subject: Re: conversions between fixed-point types Date: Sun, 20 Sep 2009 20:55:50 +0200 Organization: albasani.net Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net Ojclf8DmTG4odCngXCLwDOAZGmo0ee/iM84cCwiSSHML+t8GjZSrn67ZuSpM1imFYFIzgZLd0Qbgqk5tPkMG7aFlSou+RP5m4eca7vWWxKxrsF2IRmEGKqOOj9uDcwLZ X-Complaints-To: abuse@albasani.net NNTP-Posting-Date: Sun, 20 Sep 2009 18:55:51 +0000 (UTC) X-User-ID: Y0AcX246hREX4EWxdwmjrYtp+Nf2mUOZe7mi8FrvvLeTvTR64ZPnQDImu5PiwcDTTGR9owQPuPgPiL016TPphQ== In-Reply-To: Cancel-Lock: sha1:9bkqGaUUuk1VM3hJr1W9vVcPm0I= User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706) X-NNTP-Posting-Host: l/5P1MF8FM2QgvOtKOpfMagGeHNpFW9Tvoi15foEMAM= Xref: g2news2.google.com comp.lang.ada:8407 Date: 2009-09-20T20:55:50+02:00 List-Id: Robert A Duff wrote: > Dirk Herrmann writes: > >> In particular I am disturbed by the fact that the following two lines >> produce different results with GNAT, as has been confirmed for GNAT >> 3.15p (thanks, tmoran): > > I don't know, but it might have something to do with the rules for > evaluating static expressions. See RM-4.9. You also need to look at > G.2.3. I don't remember the exact rules for conversions of fixed > point, but I think they do allow some implementation freedom. Thanks Bob, I will look at those chapters. > If you don't like that, then write code to make it do what > you want. As I said when I started this thread, I am currently investigating whether Ada could be a good replacement for the proprietary fixed-point oriented language used in our company. And, convincing my colleagues would certainly not be easier with statements like "Ada can be used, but you have to implement all fixed-point stuff yourself". Even more if you can not even rely on the fact that a compiler will behave the same way throughout. > Or use compatible delta/small values. Fortunately, most (but not all) of our fixed-point code uses powers of two for small. But, even in that case you have to care about rounding when, for example, you are converting values from a small of 0.125 to a small of 0.5. > By the way, you can say: > > for T'Small use T'Delta; > > to avoid repeating yourself. I have tried that, especially since the very same recommendation was given in the Barnes book "Ada 2005". But, GNAT gives an error message. It seems that the very moment you reference T'Delta the type T gets "frozen" such that the "use" statement itself freezes T before it can modify it. I don't know if this is what the authors of the reference manual had intended, but GNAT interprets it that way. Thanks a lot for your help, Dirk