Re: L? Roman function

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Re: L? Roman function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-48022@lists.php.net to get a copy of this message
Hi there. I picked up this function several years ago. See if this can help you see what the roman value for an arabic number is. //Calculates the Roman numerals for the given Arabic number. // Returns '' on error. function to_roman($num) { // There is no '0' or negative numbers in Roman numerals. // Also, anything not in [0-9] is bad input. if (!ereg('^[0-9]+$', $num) || ((int)$num == 0)) { return(''); } // Do some setup $num = (int)$num; $letter[10] = array('X', 'C', 'M'); $letter[5] = array('V', 'L', 'D'); $letter[1] = array('I', 'X', 'C'); $roman = ''; // Numbers > 1000 are a special case. // (No letters > 'M') $digit = (int)($num / 1000); $num -= ($digit * 1000); while ($digit > 0) { $roman .= 'M'; $digit--; } // Do the work for ($i=2; $i>=0; $i--) { $power = pow(10, $i); $digit = (int)($num / $power); $num -= ($digit * $power); if (($digit == 9) || ($digit == 4)) { $roman .= $letter[1][$i] . $letter[$digit+1][$i]; } else { if ($digit >= 5) { $roman .= $letter[5][$i]; $digit -= 5; } while ($digit > 0) { $roman .= $letter[1][$i]; $digit--; } } } // If we didn't use up $num, something broke. if ($num > 0){ return(''); } return($roman); } On Tue, 10 Apr 2001, bill wrote: > I think L is 50. > > bill > > Kurth Bemis wrote: > > > what does the roman numeral L mean? > > > > can someone point me to a page that has all of the roman numerals and their > > English equivlents? > > > > i forgot? > > > > ~kurth > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > -- Knut ------ Knut H. Hassel Nielsen Principal Engineer / Avdelingsingeniør Norwegian University of Science and Technology / NTNU Department of Computer and Information Science / IDI N-7491 Trondheim, Norway Phone Office / Telefon jobb : (+47) 73 59 18 46 Fax Office / Telefax jobb : (+47) 73 59 17 33 Cell. Phone / Mobiltelefon : 91 59 86 06

« previous php.general (#48022) next »