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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:a6b:c3c6:: with SMTP id t189mr6318343iof.0.1553919430315; Fri, 29 Mar 2019 21:17:10 -0700 (PDT) X-Received: by 2002:aca:ba82:: with SMTP id k124mr6220574oif.110.1553919430133; Fri, 29 Mar 2019 21:17:10 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.166.215.MISMATCH!78no195006itl.0!news-out.google.com!l81ni181itl.0!nntp.google.com!136no194948itk.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 29 Mar 2019 21:17:09 -0700 (PDT) In-Reply-To: <70d9f913-d9e1-4849-b730-0ee4ebaaec23@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=113.161.84.122; posting-account=swBhQwoAAAASyh-mRsC176VDTWaaVHF2 NNTP-Posting-Host: 113.161.84.122 References: <36c2ff61-8cca-4435-995f-dfc34fa44b69@googlegroups.com> <70d9f913-d9e1-4849-b730-0ee4ebaaec23@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <0a988ba4-8e2e-41c5-88de-b126c842e290@googlegroups.com> Subject: Re: type definition for an integer with discrete range From: tranngocduong@gmail.com Injection-Date: Sat, 30 Mar 2019 04:17:10 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:56015 Date: 2019-03-29T21:17:09-07:00 List-Id: On Friday, March 29, 2019 at 11:46:48 PM UTC+7, mario.b...@gmail.com wrote: > On Friday, March 29, 2019 at 5:34:24 PM UTC+1, tranng...@gmail.com wrote: > > On Friday, March 29, 2019 at 11:10:42 PM UTC+7, mario.b...@gmail.com wrote: > > > Hello, > > > I'm looking for a way to define a type that runs from let say -100 to +100 with gaps of 5 width. Important is to make sure that a value like 7 can not be assigned to the type. > > > > > > something like: > > > > > > type number is new integer range -100 .. 100; > > > -- or > > > subtype number is integer range -100 .. 100; > > > > > > -- with this special thing or something like that: > > > for number'small use 5; -- can not applied here. works with fixed point types only > > > > > > Thanks ! > > > > That's a fixed point type. > > It is about angles to be correct. The problem is that fixed types are rounded. I tried > > type type_angle is delta 90.0 range -359.9 .. 359.9; -- unit is degrees > for type_angle'small use 90.0; > > -- but it is possible to assign a value that is not a multiple of 90 degree and even outside the domain of type_angle: > angle : type_angle := 370.0; > > I want a constraint error being raised. Actually, the domain is approximately [-450.0,+450.0], as pointed out by D. Kazakov. If you need the domain closer to [-360.0,+360.0], use smaller number'small.