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!news3.google.com!proxad.net!feeder1-2.proxad.net!newsfeed.straub-nv.de!news.albasani.net!not-for-mail From: Dirk Herrmann Newsgroups: comp.lang.ada Subject: Re: conversions between fixed-point types Date: Wed, 23 Sep 2009 22:57:16 +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 F4qOkI+qxgyQHEGfkNxV/qPLh4Kvo8rYGZdnFwBw+eKq++e8bKd0USEyclUBlAUYKW3ob4TEYkmek8jvNeYVBunBeKru0LRxvtzJXfCAIsXTojtLGhYmCAG8+LrYoXJe X-Complaints-To: abuse@albasani.net NNTP-Posting-Date: Wed, 23 Sep 2009 20:57:16 +0000 (UTC) X-User-ID: 81Y0juOBOjMabz55NJZjyMHW9uBmu4dx+89U611DO2kDeFTv746QsoTu6XWilYShUS6gssHJq9rKTTc8x4hJ2w== In-Reply-To: Cancel-Lock: sha1:b4HaS7AOwhgIzTwigBE2m5jQgTg= User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706) X-NNTP-Posting-Host: GkKocaE/zP9xNMb/TH40dGZ7xuvHkCMeyp9c37Ej0qU= Xref: g2news2.google.com comp.lang.ada:8441 Date: 2009-09-23T22:57:16+02:00 List-Id: Jeffrey R. Carter wrote: > You are complicating matters with your functions and your conversions to > and from Float. Since IIRC your target H/W doesn't support > floating-point, you will be able to see what happens and formulate your > questions better if you deal only with the fixed-point types and direct > type conversions between them: Thanks, Jeff, for the suggestions, I have tried them out. I'd like to add that our target H/W does not have a floating point unit, but there certainly is a floating point library. > What you have called a "direct cast" is a type conversion. Also, it is > never necessary to convert a real numeric literal to a real type. Your > 1st line could be written as > > FIO.Put (Float (Fpb (Float'(-1.5) ) ) ); > > With the apostrophe, this is a "qualified expression" and tells the > compiler that the expression in the parentheses is of type Float. > However, I suspect that > > FIO.Put (Float (Fpb'(-1.5) ) ); > > is even better. FpB'Image(FpB'(-1.5)) evaluates to -1.2 FpB'Image(FpB(FpA'(-1.5))) evaluates to -1.2 FpB'Image(MakeBFromA(FpA'(-1.5))) evaluates to -1.6 Thus, even avoiding all floating point operations, the difference is still there. It appears to be a question of whether the conversion from FpA to FpB or the conversion from Float to FpB is computed statically or dynamically. Best regards, Dirk