RE: Re: Now, how about Roman Numerals?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



That's great, but what about the reverse: Roman to Arabic?

George in Oxford

> -----Original Message-----
> From: nabil [mailto:nabil.attar@aws-syria.com]
> Sent: 11 June 2003 9:26 am
> To: php-db@lists.php.net
> Subject:  Re: Now, how about Roman Numerals?
> 
> 
> That's is wonderfull Hugh..
> Nabil
> 
> "Hugh Bothwell" <hugh_bothwell@hotmail.com> wrote in message
> 20030611045527.87485.qmail@pb1.pair.com">news:20030611045527.87485.qmail@pb1.pair.com...
> > "David Shugarts" <Azimuth@CompuServe.com> wrote in message
> > BB0C0EE7.21AF3%Azimuth@CompuServe.com">news:BB0C0EE7.21AF3%Azimuth@CompuServe.com...
> > > Second poser today:
> > >
> > > How to use either a MySQL select statement or PHP to produce a roman
> > > numeral, starting from an arabic (INT) number in a database?
> >
> >
> > In PHP:
> >
> >
> > function RomanDigit($dig, $one, $five, $ten) {
> >     switch($dig) {
> >         case 0:    return "";
> >         case 1:    return "$one";
> >         case 2:    return "$one$one";
> >         case 3:    return "$one$one$one";
> >         case 4:    return "$one$five";
> >         case 5:    return "$five";
> >         case 6:    return "$five$one";
> >         case 7:    return "$five$one$one";
> >         case 8:    return "$five$one$one$one";
> >         case 9:    return "$one$ten";
> >     }
> > }
> >
> > function IntToRoman($num) {
> >     if (($num < 1) || ($num > 3999))
> >         return("No corresponding Roman number!");
> >
> >     $m = $num / 1000;
> >     $c = ($num % 1000) / 100;
> >     $x = ($num % 100) / 10;
> >     $i = $num % 10;
> >
> >     return(
> >          RomanDigit($m, 'M', '', '')
> >         .RomanDigit($c, 'C', 'D', 'M')
> >         .RomanDigit($x, 'X', 'L', 'C')
> >         .RomanDigit($i, 'I', 'V', 'X')
> >     );
> > }
> >
> >
> > --
> > Hugh Bothwell     hugh_bothwell@hotmail.com     Kingston ON Canada
> > v3.1 GCS/E/AT d- s+: a- C+++ L++>+++$ P+ E- W+++$ N++ K? w++ M PS+
> > PE++ Y+ PGP+ t-- 5++ !X R+ tv b++++ DI+++ D-(++) G+ e(++) h-- r- y+
> >
> >
> >
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux