Re: RE: [PEAR] [ANNOUNCEMENT] Numbers_Words-0.7.1 (beta) Released.

From: Date: Tue, 25 May 2004 15:04:04 +0000
Subject: Re: RE: [PEAR] [ANNOUNCEMENT] Numbers_Words-0.7.1 (beta) Released.
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-29639@lists.php.net to get a copy of this message
David, David Costa wrote:
On May 25, 2004, at 4:27 PM, Antonio Carlos Venancio Junior wrote:
    That are only two examples of _wrong_ roman numbers, because 'VX' doesn't exists and its computed as a 5 (five). And the correct form of a nine (9) is 'IX' and not 'VIIII'.
This is not a problem, if you convert VX that is not a valid numeral so it's your fault I assume. Same for VIIII. It will return you a rough guess, which cannot be accurate if you pass an invalid numeral. toNumber expects a valid Numeral as input.
    Yeah, i think it _is_ a problem. You have to parse the number and raise an error when the conversion could not be made, i.e. because the user passed a "bad" roman number.
    Try to remember when you have learned semanthics (and roman numbers too). You need to understand that 'VIIII' _is not_ the representation of the number nine (9). The correct representation is 'IX'. You will never find a book with page 'VIIII', gotcha?!
You think, well first and foremost this is a BETA package. So I can change the API if needed and if I deem it appropriate. Second YOU need to understand that if you pass an invalid numeral you will get an odd/inaccurate result. Nobody can forecast all the possible numerals passed from 1 to 5999999 so if the use doesn't bother to learn how to use a package don't blame the author.
Yes, you _can_. Roman number representation follow some simple rules (regular expressions ...). The following are some general rules for constructing Roman numerals: ----------- - Characters are additive. I is 1, II is 2, and III is 3. VI is 6 (literally, “5 and 1”), VII is 7, and VIII is 8. - The tens characters (I, X, C, and M) can be repeated up to three times. At 4, you need to subtract from the next highest fives character. You can't represent 4 as IIII; instead, it is represented as IV (“1 less than 5”). The number 40 is written as XL (10 less than 50), 41 as XLI, 42 as XLII, 43 as XLIII, and then 44 as XLIV (10 less than 50, then 1 less than 5). - Similarly, at 9, you need to subtract from the next highest tens character: 8 is VIII, but 9 is IX (1 less than 10), not VIIII (since the I character can not be repeated four times). The number 90 is XC, 900 is CM. - The fives characters can not be repeated. The number 10 is always represented as X, never as VV. The number 100 is always C, never LL. - Roman numerals are always written highest to lowest, and read left to right, so the order the of characters matters very much. DC is 600; CD is a completely different number (400, 100 less than 500). CI is 101; IC is not even a valid Roman numeral (because you can't subtract 1 directly from 100; you would need to write it as XCIX, for 10 less than 100, then 1 less than 10). ----------
Of course if this is bad for your personal use, feel free to fork your own version and do it your way, by all means this is something you can do.
    That's why we need a QA team. This package certainly whould not be aproved that way. I just made an "expect to fail" test to the class that not failed. That's the basics.
-- 
I would strongly vote against you on the QA team because, in lieu of kindly and politely suggest a change, you came in and said "I ask permission to change the code" claiming something about speed (non existing issue in a static method).
So do you remember that there is no representation for zero (0), for example. The numbers goes from 1 to 3999 (including them). I'm warning you aobut that now about that and asking you to change it. If you are in doubt please try to search the web for the rules to represent roman numbers. The rules above are a very good start. If you follow them the code will be faster.
QA should act in extreme situations not when/if someone like you doesn't like the API. So your approach was wrong.
Sorry, but I think you missunderstood that. I'm not complanning about the API, but about the correctness of what the class should make.
Just because you might have karma (I don't know as have never seen something substantial committed by you) this doesn't mean you can change a code if you don't like it. Not even if you are on QA.
That`s why I've asked you in the first mail ... -- Ate' Antonio "Can't buy what I want because its FREE!" - Pearl Jam

« previous php.pear.dev (#29639) next »