comp.lang.ada
 help / color / mirror / Atom feed
From: "Staszek Goldstein" <goldstei@math.uni.lodz.pl>
Subject: output and digits
Date: Tue, 19 Apr 2005 12:34:25 +0200
Date: 2005-04-19T12:34:25+02:00	[thread overview]
Message-ID: <d42mue$2tc$1@achot.icm.edu.pl> (raw)
In-Reply-To: wccmzrvfs4i.fsf@shell01.TheWorld.com

> You can convert a Roman_Digit to a Character via
> Character'Value(Roman_Digit'Image(X)).  You can write a function to
> convert Roman_Number to String, using that in a loop.
> That's not very efficient, but it avoids the tedious mentioning
> of every Roman_Digit character in the conversion routine.

This seems like a best idea so far...

> By the way, "Roman_Digit" is a strange name -- in what sense are these
> symbols "digits"?
>

This is not a strange name - it is a very good name. A completely disagree
also with Dmitry's claim that there are only two digits in
"VIII" - there are four. In Dmitry's sense something may be a digit or not
depending on its position in the number (for example, in"MCM" the first 'M'
is a digit, and the second not). Although nothing prevents us from adopting
such a point of vue, it seems very unnatural."Numbers" are words over an
alphabet consisting of digits as much as usual "words" are words over an
alphabet consisting of letters. As such, digits may have no semantics. For
example, "101" can denote number 101 and number 3, and many others. So the
value of a string of digits depends on the way we interpret it.

>    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...

Thanks to everybody,
Staszek








  parent reply	other threads:[~2005-04-19 10:34 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-18 22:04 output of enumeration types Staszek Goldstein
2005-04-18 22:35 ` Larry Kilgallen
2005-04-18 22:43   ` Staszek Goldstein
2005-04-18 23:35   ` Staszek Goldstein
2005-04-19  0:07     ` Stephen Leake
2005-04-19  0:43       ` Staszek Goldstein
2005-04-19  4:56         ` Martin Krischik
2005-04-19 18:57         ` Jeffrey Carter
2005-04-20  0:40           ` Staszek Goldstein
2005-04-20  1:38             ` Jeffrey Carter
2005-04-19  0:33     ` Larry Kilgallen
2005-04-19  0:51       ` Staszek Goldstein
2005-04-19 23:40         ` Stephen Leake
2005-04-20  0:17           ` Staszek Goldstein
2005-04-20  9:53             ` Dmitry A. Kazakov
2005-04-20 23:16             ` Stephen Leake
2005-04-19  0:59       ` Staszek Goldstein
2005-04-19  1:54 ` Robert A Duff
2005-04-19  3:03   ` Larry Kilgallen
2005-04-19 10:34   ` Staszek Goldstein [this message]
2005-04-20 13:56     ` output and digits Robert A Duff
2005-04-20 19:53       ` Staszek Goldstein
2005-04-19  3:04 ` output of enumeration types Steve
2005-04-19  7:31 ` Dmitry A. Kazakov
2005-04-19  7:49   ` Szymon Guz
2005-04-19  8:11     ` Dmitry A. Kazakov
2005-04-19 11:26     ` Marius Amado Alves
2005-04-19 12:56       ` Dmitry A. Kazakov
2005-04-19 13:57         ` Marius Amado Alves
2005-04-19 16:05       ` Larry Kilgallen
2005-04-19 17:55         ` Georg Bauhaus
2005-04-19 21:39           ` Florian Weimer
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox