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,3cff83f35107b37b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.73.7 with SMTP id h7mr2086349pav.6.1349451662792; Fri, 05 Oct 2012 08:41:02 -0700 (PDT) Received: by 10.68.216.202 with SMTP id os10mr1336683pbc.17.1349451662776; Fri, 05 Oct 2012 08:41:02 -0700 (PDT) Path: g9ni23679pbh.1!nntp.google.com!kr7no5817795pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 5 Oct 2012 08:41:02 -0700 (PDT) In-Reply-To: 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: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <92e28d54-0c53-4e3a-a312-47a60429d2fe@googlegroups.com> Subject: Re: Multiplying fixed-point by long integer From: Adam Beneschan Injection-Date: Fri, 05 Oct 2012 15:41:02 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-10-05T08:41:02-07:00 List-Id: On Thursday, October 4, 2012 9:25:33 PM UTC-7, (unknown) wrote: > Create a 2nd fixed point type big enough to hold your long integer, and > multiply by that? You know, I thought of that last night, after I had posted it. But that ra= ises another problem. I assume you're thinking of something like this: type Long_Fixed is delta 1.0 range Long_Integer'First .. Long_Integer'Las= t; F1, F2 : Some_Other_Fixed_Type; F2 :=3D F1 * Long_Fixed(N); except that the Long_Fixed declaration isn't legal, because the range bound= s have to be of a real type. But how do you get the bounds to be real? type Long_Fixed is delta 1.0 range Long_Float(Long_Integer'First) .. Long_Float(Long_Integer'Last); This isn't right, because it's possible that the largest floating-point typ= e supported by the implementation has a mantissa size smaller than the numb= er of bits in a Long_Integer (or, if you like, Long_Long_Integer or Interfa= ces.Integer_64), which means that the result won't be exactly right. This seems like a flaw in the language, that it supports a "universal real"= type for static values that can be indefinitely precise, but there's no w= ay to convert a static integer value to a universal real without going thro= ugh a predefined floating-point type that may be less accurate than the int= eger. Of course, the problem at hand could be solved with something like type Long_Fixed is delta 1.0 range -2.0**(Long_Integer'Size - 1) .. 2.0**(Long_Integer'Size - 1) - 1.0; Seems a bit hokey that you have to go through this, though. -- Adam