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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,65b3f028266fd999 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!gegeweb.org!aioe.org!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Question about ordinary fixed point types. Date: Mon, 16 Aug 2010 00:08:19 +0200 Organization: Ada At Home Message-ID: References: <4c685fac$0$2373$4d3efbfe@news.sover.net> NNTP-Posting-Host: RZkTY5NyuNCeyE5VNfPAfQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Opera Mail/10.61 (Win32) Xref: g2news1.google.com comp.lang.ada:13370 Date: 2010-08-16T00:08:19+02:00 List-Id: Hi Peter, nice to see you again, Le Sun, 15 Aug 2010 23:43:43 +0200, Peter C. Chapin a = = =C3=A9crit: > I have a need to work with ordinary fixed point types. I've read the i= n > the reference manual about them (section 3.5.9, for example), and some= > other things. I still have a few questions. I thought I'd start with o= ne > here. > > Consider this example: > > > type Angle_Type is delta 0.0005 range -3.1416 .. 3.1416; > Angle : Angle_Type; > ... > Angle :=3D Angle_Type'First; > while Angle < Angle_Type'Last loop > -- Work with Angle here. > Angle :=3D Angle + Angle_Type'Small; > end loop; OK. > Aside from Angle_Type'Last does the loop above reliably visit every > possible value of Angle_Type? By "reliably" I mean "has the desired > effect on all possible correct Ada implementations." I guess my questi= on > is: does Angle + Angle_Type'Small always advance Angle to the next > machine number in the type? What do you mean with =E2=80=9Cto the next machine number in the type=E2= =80=9D ? That this = may not advance in some case ? > I'm using GNAT GPL 2010 and in the example above GNAT appears to be > using 2**(-11) for Angle_Type'Small. So a bit less than the desired 0.0005 If the matter is the precise exploration of a precise set of points in a= = range, I may have a silly suggestion (silly in some sense, while not so = = much in some others) : why not use an array of predefined points ? Here,= = you would have an array of 12566 points. Ok, this may seems a big array,= = some design for hight efficiency. But this would come with the benefit o= f = an precise and may be adjustable point by point, set of points. The = Quality of this set of point could be precisely evaluated and adjusted. = = This is relevant here, as any way, you will never get exact value, becau= se = as you noticed, the delta does not allow to exactly match the range. What is the purpose of the exploration ? Sampling at normalized position= = or something of the like ? I would be very interested to know more about the intended use. This wil= l = learn us a lot of things. -- = There is even better than a pragma Assert: a SPARK --# check. --# check C and WhoKnowWhat and YouKnowWho; --# assert Ada; -- i.e. forget about previous premises which leads to conclusion -- and start with new conclusion as premise.