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: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>

-- 
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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to