On 18/09/2013 16:19, Bart wrote: > RomanToInt acceps rather ludicrous values: > > RomanToInt('MDCLXVIVXLDM') = 2209 > RomanToInt('IIIIM') = 1002 //calculated as 3 + (1000-1) > > Both examples represent invalid roman numbers by any standard. > Also I do not think Roman numerals can be negative... > > Feature or bug? >
1. I'll respond with the expected answer: "What does Delphi do" (if it has this function? 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. 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. [1] http://lazarus-ccr.sourceforge.net/docs/rtl/strutils/romantoint.html _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal