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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,184737148aef02ac X-Google-Attributes: gid103376,public From: robert_dewar@my-dejanews.com Subject: Re: Fixed point multiplication ambiguity Date: 1999/01/28 Message-ID: <78q6al$hi5$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 437861540 References: <78od6d$b4t$2@plug.news.pipex.net> X-Http-Proxy: 1.0 x6.dejanews.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Thu Jan 28 17:21:34 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-01-28T00:00:00+00:00 List-Id: In article , stt@houdini.camb.inmet.com (Tucker Taft) wrote: > The whole fixed-point multiplication model is pretty > obscure, unfortunately. I agree with Tuck's analysis in its entirety. Note that the model may be a bit obscure, but the normal practice of qualifying intermediate results returned by multiplication using an explicit conversion removes this obscurity. I actually find the implicit use of Duration MOST unfortunate. GNAT finds it worrying enough to emit a warning: 1. procedure Tf is 2. D : Duration := 5.0; 3. Dec_Delt : Integer := Integer (D * 10.0 + 0.5) | >>> warning: Universal-fixed expression interpreted as type "Standard.Duration" 4. begin 5. null; 6. end; Since it really seems strange to have Duration creeping in here. Note that this is NOT related to the declaration of D as being of type Duration, it would happen if D were of some other fixed point type, as long as it was not a visible type at the point of the expression. If two fixed-point types *are* visible, then GNAT says 1. procedure Tf2 is 2. type r is delta 1.0 range -10.0 .. +10.0; 3. D : r := 5.0; 4. Dec_Delt : Integer := Integer (D * 10.0 + 0.5); | >>> ambiguous universal_fixed_expression >>> possible interpretation as type Standard.Duration" >>> possible interpretation as type "r" defined at line 2 5. begin 6. null; 7. end; It could still confuse a beginner :-) but it is hard to see how one can do better error-message wise! -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own