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,9ce828272f314121 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!news-east.rr.com!news.rr.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!news.mv.net!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: output and digits Date: 20 Apr 2005 09:56:51 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1114005411 30453 192.74.137.71 (20 Apr 2005 13:56:51 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 20 Apr 2005 13:56:51 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:10609 Date: 2005-04-20T09:56:51-04:00 List-Id: "Staszek Goldstein" writes: > > type Roman_Digit is ('I','V','X','L','C','D','M'); > > for Roman_Digit use ('I' => Character'('I')'val, > > 'V' => ...); > > > > Then Unchecked_Conversion from Roman_Digit to Character will work. > > Except that you then need to order the Roman_Digits in the same > > order as in Character: "... is ('C', 'D', ..., 'X')". > > This works (if you correct it slightly to integer(character'pos('I')) - pos > gives a universal integer!), but changing the order does not seem nice in a > language like Ada... Oops. Yeah, 'Pos is what you want. But you don't need the conversion to Integer. What you *really* want is: subtype Roman_Digit is Character restricted to ('I','V','X','L','C','D','M'); -- Not Ada! or perhaps: type Roman_Digit is new Character restricted to ('I','V','X','L','C','D','M'); -- Not Ada! Actually, it makes no sense to do arithmetic on roman numerals. So if I were doing this, I would have two functions, for converting integers to/from roman numerals represented as Strings. You only need roman numerals for I/O. All internal processing can be done in integers. That's how you'd do it an any language. - Bob