User Control Panel
|
|
|
 |
Advertisements
|
 |
|
|
|
HELP US, HELP YOU!
|
| Author |
Message |
mat007 Almost An Agent

Joined: 12 Jan 2004 Posts: 1375
   votes: 2
|
Posted: Sat Dec 18, 2004 12:51 pm Post subject: |
|
|
This service converts arabic numbers (1 - 3,999) to roman numerals and vice-versa from i to mmmcmxcix.
To use the service go to: http://plazmabot.com/cgi-bin/service.cgi?service=roman&amm=
Replace with a number or a roman numeral.
Hope you like  |
|
| Back to top |
|
 |
purcelly God Like

Joined: 10 Jun 2004 Posts: 560 Location: North West, England
    
|
Posted: Sat Dec 18, 2004 3:03 pm Post subject: |
|
|
| Nice another good service |
|
| Back to top |
|
 |
stof91 Newbie

Joined: 29 Sep 2004 Posts: 33
  
|
Posted: Sat Dec 18, 2004 4:35 pm Post subject: |
|
|
Cool 
Keep up the good Work  |
|
| Back to top |
|
 |
mattaustin Sentinel

Joined: 19 Jul 2004 Posts: 556 Location: Los Angeles, CA
  votes: 1
|
Posted: Sat Dec 18, 2004 5:42 pm Post subject: |
|
|
you could save the lwp post and figure the Roman Conversion in your code:
| Code: | | my $num = 129;<br />my ($one,$ten,$hun) = split(//, reverse $num);<br />my $ret = 'M' x int($num/1000).<br /> (('','C','CC','CCC','CD','D','DC','DCC','DCCC','CM')[$hun]).<br /> (('','X','XX','XXX','XL','L','LX','LXX','LXXX','XC')[$ten]).<br /> (('','I','II','III','*lazy*','V','VI','VII','VIII','IX')[$one]);<br />print $ret; |
edit: give me a sec and ill write a reverse
| Code: | | if($num =~ /^(?: M{0,3})(?: D?C{0,3} | C[DM])(?: L?X{0,3} | X[LC])(?: V?I{0,3} | I[VX])$/ix){<br /> my %roman2arabic = qw(I 1 V 5 X 10 L 50 C 100 D 500 M 1000);<br /> foreach (split(//, uc $num)) {<br /> my($digit) = $roman2arabic{$_};<br /> $ret -= 2 * $last_digit if $last_digit < $digit;<br /> $ret += ($last_digit = $digit);<br /> }<br />print "$ret";<br />}<br />else{<br /> my ($one,$ten,$hun) = split(//, reverse $num);<br /> my $ret = 'M' x int($num/1000).<br /> (('','C','CC','CCC','CD','D','DC','DCC','DCCC','CM')[$hun]).<br /> (('','X','XX','XXX','XL','L','LX','LXX','LXXX','XC')[$ten]).<br /> (('','I','II','III','*lazy*','V','VI','VII','VIII','IX')[$one]);<br /> print "$ret";<br /> } |
_________________ [ matt ] |
|
| Back to top |
|
 |
Mojave Almost An Agent

Joined: 01 Nov 2003 Posts: 1434
 
|
Posted: Sat Dec 18, 2004 7:12 pm Post subject: |
|
|
I really like services!
But matt's code is pretty cool too.
And finally, there's a Perl module at CPAN and some more for doing the conversion. |
|
| Back to top |
|
 |
|
|