Documentation on RomanToInt is wrong w.r.t. "invalid characters".
Original Reporter info from Mantis: Bart @flyingsheep
-
Reporter name: Bart Broersma
Original Reporter info from Mantis: Bart @flyingsheep
- Reporter name: Bart Broersma
Description:
Docs say: "RomanToInt returns the decimal equivalent of the Roman numerals in the string S. Invalid characters are dropped from S".
Dropped would suggest that the characters were not "translated", so e.g. 'MCAZ' would be treated as 'MC'.
In fact any illegal character in S will make the function return 0 (zero).
Steps to reproduce:
program test;
{$mode objfpc}
{$H+}
uses
StrUtils;
begin
writeln('RomanToInt(''MCA'') = ',RomanToInt('MCA'));
end.
C:\Users\Bart\LazarusProjecten\ConsoleProjecten>fpc test.pas
Free Pascal Compiler version 2.6.2 [2013/02/12] for i386
Copyright (c) 1993-2012 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling test.pas
Linking test.exe
14 lines compiled, 2.7 sec , 59712 bytes code, 12796 bytes data
C:\Users\Bart\LazarusProjecten\ConsoleProjecten>test
RomanToInt('MCA') = 0
Additional information:
"RomanToInt returns the decimal equivalent of the Roman numerals" is open for interpretation as well.
The equivalent of 'MIIM' should by all means be: "this is not a valid Roman numeral" and not 2000 (calcutated as 1000 + 1 + (1000 - 1)).
Mantis conversion info:
- Mantis ID: 25061
- Version: 2.6.2
- Fixed in version: 3.0.0
- Fixed in revision: 1065 (#bddf1e64)
- Target version: 3.0.0