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,3cff83f35107b37b X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.72.134 with SMTP id d6mr720282pav.20.1352234032986; Tue, 06 Nov 2012 12:33:52 -0800 (PST) Received: by 10.68.130.68 with SMTP id oc4mr791609pbb.3.1352234032970; Tue, 06 Nov 2012 12:33:52 -0800 (PST) Path: 6ni63996pbd.1!nntp.google.com!kr7no34493229pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 6 Nov 2012 12:33:52 -0800 (PST) In-Reply-To: <87y5ievea3.fsf@adaheads.sparre-andersen.dk> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ NNTP-Posting-Host: 66.126.103.122 References: <87y5ievea3.fsf@adaheads.sparre-andersen.dk> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Multiplying fixed-point by long integer From: Adam Beneschan Injection-Date: Tue, 06 Nov 2012 20:33:52 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-11-06T12:33:52-08:00 List-Id: On Tuesday, November 6, 2012 9:20:55 AM UTC-8, Jacob Sparre Andersen wrote: > Adam Beneschan writes:=20 >=20 > > 4.5.5 defines predefined multiplication operators between any > > fixed-point type and Integer. However, it isn't defined for any other > > integer type. >=20 > Is there a reason for that? (I can't find anything in the AARM.) Having it predefined for more than one integer type would lead to ambiguiti= es if you gave it an integer literal, which is probably one of the most com= mon cases. That is, if F is an object of a fixed-point type, something lik= e F :=3D F * 3; won't compile if "*" were defined multiple times for a fixed-point type and= more than one integer type. The same issue arises with the "**" operator which is predefined only for a= n Integer right operand. That shouldn't be a real problem, however, since = if N is a value that will fit in a Long_Integer but not an Integer, you're = not going to be able to usefully raise anything to the Nth power anyway. I proposed a suggested solution to Ada-Comment that involved a new language= -defined generic, since I didn't want to add to the mess involving predefin= ed fixed-point multiplication and name resolution rules (there have already= been some issues with that that probably caused the ARG some headaches). = Tucker pointed out to me that there was a way to get it done without involv= ing predefined floating-point types: type Long_Fixed is delta 1.0 range Long_Integer'Pos(Long_Integer'First) * 1.0 .. Long_Integer'Pos(Long_Integer'Last) * 1.0; and then use predefined "*" between two fixed-point types, converting the L= ong_Integer to Long_Fixed. Seems like a roundabout way of doing things, bu= t probably acceptable given that the need for this is probably pretty uncom= mon. -- Adam