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 X-Google-Thread: 103376,c42dbf68f5320193 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-25 09:25:43 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-out.nuthinbutnews.com!propagator-sterling!news-in.nuthinbutnews.com!news.stealth.net!news.stealth.net!news-east.rr.com!chnws02.ne.ipsvc.net!cyclone.ne.ipsvc.net!24.128.8.70!typhoon.ne.ipsvc.net.POSTED!not-for-mail Message-ID: <3CEFBB58.906@attbi.com> From: "Robert I. Eachus" Organization: Eachus Associates User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4.1) Gecko/20020314 Netscape6/6.2.2 X-Accept-Language: en,pdf MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Generation of permutations References: <5ee5b646.0205041652.63032ba6@posting.google.com> <3CDAB578.6F32339D@san.rr.com> <3CDAE30B.CFFB6F29@san.rr.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 25 May 2002 16:21:31 GMT NNTP-Posting-Host: 24.61.239.24 X-Complaints-To: abuse@attbi.com X-Trace: typhoon.ne.ipsvc.net 1022343691 24.61.239.24 (Sat, 25 May 2002 12:21:31 EDT) NNTP-Posting-Date: Sat, 25 May 2002 12:21:31 EDT Xref: archiver1.google.com comp.lang.ada:24770 Date: 2002-05-25T16:21:31+00:00 List-Id: Darren New wrote: > "A given set of instructions" means whatever set I give you, not one > that you get to pick. This is normal math-speak, so I'm not surprised > that it was considered implied. Consider > > function square(a : double) return double is return a * a; end square; > -- (assuming I got the syntax right) > > This "squares a given number". I.e., it squares whatever number you give > it. If it doesn't work for any number you give it, then it doesn't > "square a given number", at least in normal math-speak. Wow! What a fascinating question: For what Ada types "double" does this actually provide the square of a number? Another related question is whether it returns the correct value or raises an exception. Not true for all integer types, but true for type Double is range 0..1; If you use the looser definition, then true for all integer types. True for all modular types. Modular values do not have unique square roots, but that is a normal property of squares. All modular types are closed under multiplication, and will never result in an exception. (With Storage_Error always a possibility, but an uninteresting one.) False in both senses for floating-point types. There are values which will result in IEEE infinities or overflow. (Underflow is not possible.) But for only a small subset of the representable real values is the square also exactly representable. For fixed-point types, the question gets really hairy. There are trivial fixed point types for which it is true. For other fixed-point types, the multiplication returns the correct result, but rounding or truncation can occur on the implicit conversion to double. This will not occur for 'SMALLs which are a multiple of 1.0. The implicit assignment in the return statement may raise Contraint_Error, but for which ranges? Constraint_Error will not be raised for null ranges, for the range 0.0..0.0, for ranges of -1.0..1.0, and ranges of the form X..1.0 for X non-negative. However, there is a special case to be aware of. For types with an upper bound of 1.0, or with a declaration of the form type double is range N..1.0 - M delta M, it is possible for double'Last * double'Last to raise Constraint_Error. This can also occur for x * x when x = -1.0 even if double'last is 1.0. I'm not even going to touch complex types from the Numerics Annex. ;-)