<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: JavaScript Roman Numeral Converter</title>
	<atom:link href="http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter</link>
	<description>A JavaScript and regular expression centric blog</description>
	<lastBuildDate>Fri, 12 Mar 2010 20:14:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: John Vivenzio</title>
		<link>http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter/comment-page-1#comment-32064</link>
		<dc:creator>John Vivenzio</dc:creator>
		<pubDate>Sat, 02 May 2009 05:19:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter#comment-32064</guid>
		<description>... and using the same table here&#039;s the recursive decode:

var n = [
// using lowercase to represent Unicode lined Roman Numerals
[1000000, &quot;m&quot;],
[ 500000, &quot;d&quot;],
[ 100000, &quot;c&quot;],
[  90000, &quot;cm&quot;],
[  50000, &quot;l&quot;],
[  10000, &quot;x&quot;],
[   9000, &quot;xc&quot;],
[   5000, &quot;v&quot;],
[   4000, &quot;iv&quot;],
[   1000, &quot;M&quot;],
[    900, &quot;CM&quot;],
[    500, &quot;D&quot;],
[    100, &quot;C&quot;],
[     90, &quot;XC&quot;],
[     50, &quot;L&quot;],
[     40, &quot;XL&quot;],
[     10, &quot;X&quot;],
[      9, &quot;IX&quot;],
[      5, &quot;V&quot;],
[      4, &quot;IV&quot;],
[      1, &quot;I&quot;],
[      0]
];

var output = [];
var i = 0, x = 0;
var arabic = 0;

function makeArabic(numbers) {
    for (i = 0; numbers.length &amp;&amp; n[i][0]; i++)
        if (numbers.substring(0,n[i][1].length) == n[i][1]) {
            arabic += n[i][0];
            return makeArabic(numbers.substring(n[i][1].length));
        }
    return arabic;
}

makeArabic(&quot;MCMXLIX&quot;);</description>
		<content:encoded><![CDATA[<p>&#8230; and using the same table here&#8217;s the recursive decode:</p>
<p>var n = [<br />
// using lowercase to represent Unicode lined Roman Numerals<br />
[1000000, "m"],<br />
[ 500000, "d"],<br />
[ 100000, "c"],<br />
[  90000, "cm"],<br />
[  50000, "l"],<br />
[  10000, "x"],<br />
[   9000, "xc"],<br />
[   5000, "v"],<br />
[   4000, "iv"],<br />
[   1000, "M"],<br />
[    900, "CM"],<br />
[    500, "D"],<br />
[    100, "C"],<br />
[     90, "XC"],<br />
[     50, "L"],<br />
[     40, "XL"],<br />
[     10, "X"],<br />
[      9, "IX"],<br />
[      5, "V"],<br />
[      4, "IV"],<br />
[      1, "I"],<br />
[      0]<br />
];</p>
<p>var output = [];<br />
var i = 0, x = 0;<br />
var arabic = 0;</p>
<p>function makeArabic(numbers) {<br />
    for (i = 0; numbers.length &amp;&amp; n[i][0]; i++)<br />
        if (numbers.substring(0,n[i][1].length) == n[i][1]) {<br />
            arabic += n[i][0];<br />
            return makeArabic(numbers.substring(n[i][1].length));<br />
        }<br />
    return arabic;<br />
}</p>
<p>makeArabic(&#8220;MCMXLIX&#8221;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Vivenzio</title>
		<link>http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter/comment-page-1#comment-32062</link>
		<dc:creator>John Vivenzio</dc:creator>
		<pubDate>Sat, 02 May 2009 04:50:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter#comment-32062</guid>
		<description>Ok - now I&#039;m hooked on these teasers! : )

Quick variation on the 2 line makeChange algorithm to encode:

(does multi million conversions - though I can see how they&#039;d read that fast enough to be of any use - can you picture the bailout being accounted for in roman numerals? How much graft do you think they&#039;d be able to get away with using accounting sheets with:

all numbers in Ms: mdccccvMMDCCCLIX * mmmdccvMDCLIX ! : )

var n = [
// using lowercase to represent Unicode lined Roman Numerals
[1000000, &quot;m&quot;],
[ 500000, &quot;d&quot;],
[ 100000, &quot;c&quot;],
[  90000, &quot;cm&quot;],
[  50000, &quot;l&quot;],
[  10000, &quot;x&quot;],
[   9000, &quot;xc&quot;],
[   5000, &quot;v&quot;],
[   4000, &quot;iv&quot;],
[   1000, &quot;M&quot;],
[    900, &quot;CM&quot;],
[    500, &quot;D&quot;],
[    100, &quot;C&quot;],
[     90, &quot;XC&quot;],
[     50, &quot;L&quot;],
[     40, &quot;XL&quot;],
[     10, &quot;X&quot;],
[      9, &quot;IX&quot;],
[      5, &quot;V&quot;],
[      4, &quot;IV&quot;],
[      1, &quot;I&quot;],
[      0]
];

var output = [];
var i = 0, x = 0;

function makeRoman(money) {
    for (x = Math.floor(money / n[i][0]); x; x--)
        output.push(n[i][1]);
    return isNaN(n[i + 1]) ? makeRoman(money % n[i++][0]) : output;
}

makeRoman(17996).join(&quot;&quot;);</description>
		<content:encoded><![CDATA[<p>Ok &#8211; now I&#8217;m hooked on these teasers! : )</p>
<p>Quick variation on the 2 line makeChange algorithm to encode:</p>
<p>(does multi million conversions &#8211; though I can see how they&#8217;d read that fast enough to be of any use &#8211; can you picture the bailout being accounted for in roman numerals? How much graft do you think they&#8217;d be able to get away with using accounting sheets with:</p>
<p>all numbers in Ms: mdccccvMMDCCCLIX * mmmdccvMDCLIX ! : )</p>
<p>var n = [<br />
// using lowercase to represent Unicode lined Roman Numerals<br />
[1000000, "m"],<br />
[ 500000, "d"],<br />
[ 100000, "c"],<br />
[  90000, "cm"],<br />
[  50000, "l"],<br />
[  10000, "x"],<br />
[   9000, "xc"],<br />
[   5000, "v"],<br />
[   4000, "iv"],<br />
[   1000, "M"],<br />
[    900, "CM"],<br />
[    500, "D"],<br />
[    100, "C"],<br />
[     90, "XC"],<br />
[     50, "L"],<br />
[     40, "XL"],<br />
[     10, "X"],<br />
[      9, "IX"],<br />
[      5, "V"],<br />
[      4, "IV"],<br />
[      1, "I"],<br />
[      0]<br />
];</p>
<p>var output = [];<br />
var i = 0, x = 0;</p>
<p>function makeRoman(money) {<br />
    for (x = Math.floor(money / n[i][0]); x; x&#8211;)<br />
        output.push(n[i][1]);<br />
    return isNaN(n[i + 1]) ? makeRoman(money % n[i++][0]) : output;<br />
}</p>
<p>makeRoman(17996).join(&#8220;&#8221;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: How to convert Roman Numerals and Arabic numbers in ActionScript 3 &#124; SWF It Good</title>
		<link>http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter/comment-page-1#comment-25234</link>
		<dc:creator>How to convert Roman Numerals and Arabic numbers in ActionScript 3 &#124; SWF It Good</dc:creator>
		<pubDate>Wed, 17 Dec 2008 15:01:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter#comment-25234</guid>
		<description>[...] This past week I worked on a porting exercise. I have always wanted to find out how you convert Roman Numerals to Arabic numerals and vice versa. So I starting searching and found a bunch of bloated code for converting these numbers then I stumbled on this page. [...]</description>
		<content:encoded><![CDATA[<p>[...] This past week I worked on a porting exercise. I have always wanted to find out how you convert Roman Numerals to Arabic numerals and vice versa. So I starting searching and found a bunch of bloated code for converting these numbers then I stumbled on this page. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nILS</title>
		<link>http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter/comment-page-1#comment-25030</link>
		<dc:creator>nILS</dc:creator>
		<pubDate>Sat, 11 Oct 2008 04:19:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter#comment-25030</guid>
		<description>Thanks you guys, I was looking for just that!</description>
		<content:encoded><![CDATA[<p>Thanks you guys, I was looking for just that!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: StuartMail</title>
		<link>http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter/comment-page-1#comment-16700</link>
		<dc:creator>StuartMail</dc:creator>
		<pubDate>Fri, 28 Mar 2008 14:35:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter#comment-16700</guid>
		<description>Steve
Just to say thank you for the explaination of adding leading + to input strings to stop parseInt from treating numbers (parsed in as strings) with leading zeros as Octal - solved a tricky problem for me with just one character added to my code :-)
Stuart Mail</description>
		<content:encoded><![CDATA[<p>Steve<br />
Just to say thank you for the explaination of adding leading + to input strings to stop parseInt from treating numbers (parsed in as strings) with leading zeros as Octal &#8211; solved a tricky problem for me with just one character added to my code <img src='http://blog.stevenlevithan.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
Stuart Mail</p>
]]></content:encoded>
	</item>
</channel>
</rss>
