[fpc-pascal] Re: StrUtils.RomanToInt oddities

Bart bartjunk64 at gmail.com
Fri Sep 20 18:33:06 CEST 2013


On 9/20/13, Reinier Olislagers <reinierolislagers at gmail.com> wrote:

> 1. I'll respond with the expected answer: "What does Delphi do" (if it
> has this function?

D7 PE does not have it.

> 2. I wouldn't be bothered by negative numbers... even the Romans used to
> have negative posessions (= debts) and they didn't have double entry
> bookkeeping yet ;) Also, the documentation [1] mentions it as a feature.

If I mention in documentationn that result is unpredicted for any
input e.g. for function StrToInt(S), because ATMI implemented it like
Result := StringOfChar(Char(Random(256)),Random(256)), then this would
also not considered to be a bug, just it because does what the docs
say?

> 3. The rest... well, depending on 1. I'd agree it's a bug.
> [1] mentions "Invalid characters are dropped from S"... which I think is
> a bit strange (S is a const) but assuming it means "Invalid characters
> in S are ignored" it means somebody thought checking the input for valid
> Roman numbers was a good idea. The question however becomes "what is the
> algorithm for deciding invalid characters" which IMO will become a mess
> very quickly. Much better to just consider the entire input as invalid.

Any invalid char in S will result in Result being 0;
So doc is wrong about that.

Bart



More information about the fpc-pascal mailing list