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,65b3f028266fd999,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!novia!transit4.readnews.com!news-out.readnews.com!postnews3.readnews.com!not-for-mail Date: Sun, 15 Aug 2010 17:43:43 -0400 From: "Peter C. Chapin" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Question about ordinary fixed point types. Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4c685fac$0$2373$4d3efbfe@news.sover.net> Organization: SoVerNet (sover.net) NNTP-Posting-Host: 640a69ea.news.sover.net X-Trace: DXC=kbV:S`PmgR=IK6_LM2JZB_3`HF79]IKb80^KZ4X^8KgI8X096c3NCF37> I have a need to work with ordinary fixed point types. I've read the in 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 one here. Consider this example: type Angle_Type is delta 0.0005 range -3.1416 .. 3.1416; Angle : Angle_Type; ... Angle := Angle_Type'First; while Angle < Angle_Type'Last loop -- Work with Angle here. Angle := Angle + Angle_Type'Small; end loop; 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 question is: does Angle + Angle_Type'Small always advance Angle to the next machine number in the type? I'm using GNAT GPL 2010 and in the example above GNAT appears to be using 2**(-11) for Angle_Type'Small. It thus uses something over 12,000 values for the type. The code above is for a test program; it is my intention to exercise every possible value. As an aside it appears as if Angle_Type'First is actually slightly less than the -3.1416 mentioned in the type definition. My reading of the Ada standard is that this is okay. Specifically I should be getting a multiple of Angle_Type'Small that is closest to the mathematical value of -3.1416. Apparently the closest multiple is just "to the left" of the number I specified. This actually works out to be slightly awkward in my case, but that's a problem I can probably figure out. Thanks! Peter