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-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 10:15:49 +0200 Organization: albasani.net Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net zrVNeXP9guJTljp+65mrV7h4Uro7vVuE7KHu5LO7hi/xuYWdDPOBT9FFvstmVfPSMS44+xd72ST+mfpKeRUeRgFNNznwKPYloW1wpOuJ4+J87Q/hQCz5lzHzG00j35E4 X-Complaints-To: abuse@albasani.net NNTP-Posting-Date: Sun, 20 Sep 2009 08:15:49 +0000 (UTC) X-User-ID: De7O6/rVRuXhk5qNrXEmRT5Em0JQQUFmUYjnSQ13ztTRqut9S4QmMah7Sg4HK2LjvSdJYL2995PKatQhOYrUeQ== In-Reply-To: Cancel-Lock: sha1:3pLsEBF7zcJP4RD2deHOyzcfz/U= User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706) X-NNTP-Posting-Host: p3pG0j44w36ctcwibm/vGEqE1XXtInH0Cb7F74td8lo= Xref: g2news2.google.com comp.lang.ada:8401 Date: 2009-09-20T10:15:49+02:00 List-Id: Dirk Herrmann wrote: >> And, while experimenting and trying out Adam Beneschan's solution for >> rounding (thanks for your answer, Alan) I got totally confused >> because of the following code (I am using GNAT 4.3.4 with the >> following command line options: gnatmake -f -gnatVa -gnata >> -gnatwadhl.o -save-temps conversion.adb): > [...] >> Is this confusing behaviour allowed? I will submit a bug report if >> some expert confirms it is a GNAT bug. John B. Matthews wrote: > I'm no expert, and I had some trouble following the conversions in your > example. [...] Sorry, I should have given more details about why I am confused. 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): FIO.Put(Float(FpB(Float(-1.5)))); TIO.Put(" "); --> -1.20000E+00 FIO.Put(Float(MakeB(-1.5))); TIO.Put(" "); --> -1.60000E+00 In the first line, the conversion to FpB is done from a Float value, which is a direct cast from -1.5. In the second line, the conversion to FpB is also done from a Float value, but in this case -1.5 is passed as a Float argument to MakeB. What I don't understand is, why it should make a difference whether I cast -1.5 to Float and then convert it to FpB compared to the situation where -1.5 is converted to a Float argument, which is then converted to FpB. The same question arises for the following three lines: FIO.Put(Float(FpB(FpA(Float(-1.5))))); TIO.Put(" "); --> -1.20000E+00 FIO.Put(Float(MakeBFromA(FpA(-1.5)))); TIO.Put(" "); --> -1.60000E+00 FIO.Put(Float(MakeBViaA(-1.5))); TIO.Put(" "); --> -1.60000E+00 Again, the difference lies in whether a sequence of casts is used compared to whether the very same value is passed as an argument. Thanks for your help, Dirk Herrmann (email address gladly given on request)