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-Google-Thread: 103376,c406e0c4a6eb74ed X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews2.google.com!not-for-mail From: chad.rmeiners@gmail.com (Chad R. Meiners) Newsgroups: comp.lang.ada Subject: Re: ADA Popularity Discussion Request Date: 8 Sep 2004 22:38:00 -0700 Organization: http://groups.google.com Message-ID: <782e906e.0409082138.20369fc8@posting.google.com> References: <49dc98cf.0408110556.18ae7df@posting.google.com> <87eklg62x8.fsf@news.bourguet.org> NNTP-Posting-Host: 67.167.137.13 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1094708281 26416 127.0.0.1 (9 Sep 2004 05:38:01 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 9 Sep 2004 05:38:01 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:3526 Date: 2004-09-08T22:38:00-07:00 List-Id: "jayessay" wrote in message news:m3acw0bl1u.fsf@rigel.goldenthreadtech.com... > with Text_Io; use Text_Io; > > procedure Foo is > > type Hex_Num is mod 16; > > function Hext (N : Integer) return Hex_Num is > begin > -- == (1+ (n mod 16)), which is the logic error. > return Hex_Num(1 + (N mod Hex_Num'Modulus)); > end Hext; However, most Ada programmers would have written it like procedure Foo is type Hex_Num is mod 16; function To_Hex_Num(Item : Integer) return Hex_Num is begin -- This function provides the correct conversion -- for use by all other subroutines. return Hex_Num(Item mod Hex_Num'Modulus); end To_Hex_Num; function Hext (N : Integer) return Hex_Num is begin return 1 + To_Hex_Num(N); -- Note To_Hex_Num(1+N) also works end Hext; ... and avoided the problem altogether. -CRM