<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>CodeProject: A Money type for the CLR. Free source code and programming help</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Description" content="A convenient, high-performance money structure for the CLR which handles arithmetic operations, currency types, formatting, and careful distribution and rounding without loss.; Author: codekaizen; Section: Algorithms & Recipes; Chapter: General Programming">
<meta name="Keywords" content=".NET 2.0, C# 2.0, .NET 3.0, C# 3.0, .NET 3.5, C#, .NET, Architect, Dev, Intermediate,Algorithms & Recipes,General Programming,Free source code, tutorials">
<meta name="Author" content="The Code Project">
<meta name="Rating" content="General">
<meta name="Robots" content="index, follow">
<meta name="Revisit-After" content="1 days">
<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - All topics" href="http://www.codeproject.com/webservices/articlerss.aspx?cat=1">
<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - MFC / C++" href="http://www.codeproject.com/webservices/articlerss.aspx?cat=2">
<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - C#" href="http://www.codeproject.com/webservices/articlerss.aspx?cat=3">
<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - ASP.NET" href="http://www.codeproject.com/webservices/articlerss.aspx?cat=4">
<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - .NET" href="http://www.codeproject.com/webservices/articlerss.aspx?cat=5">
<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - VB.NET" href="http://www.codeproject.com/webservices/articlerss.aspx?cat=6">
<link rel="alternate" type="application/rss+xml" title="CodeProject Lounge Postings" href="http://www.codeproject.com/webservices/LoungeRSS.aspx">
<link rel="search" type="application/opensearchdescription+xml" title="CodeProject" href="http://www.codeproject.com/info/OpenSearch.xml">
<link rel="stylesheet" type="text/css" href="MoneyTypeForCLR.aspx_files/CodeProject.css">
<link rel="stylesheet" type="text/css" href="MoneyTypeForCLR.aspx_files/ForumClassic.css">
<!-- base -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><script src="MoneyTypeForCLR.aspx_files/ga.js" type="text/javascript"></script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-1735123-1");
pageTracker._setDomainName("www.codeproject.com");
pageTracker._setSessionTimeout("1200"); // 20 mins
pageTracker._initData();
pageTracker._trackPageview();
</script>
<script type="text/javascript" language="Javascript" src="MoneyTypeForCLR.aspx_files/oncopy.js"></script>
<script type="text/javascript" language="Javascript" src="MoneyTypeForCLR.aspx_files/jxs.js"></script>
<script type="text/javascript" language="Javascript" src="MoneyTypeForCLR.aspx_files/bookmark.js"></script>
<script type="text/javascript" language="Javascript" src="MoneyTypeForCLR.aspx_files/rateitem.js"></script>
<script type="text/javascript" language="Javascript">//<![CDATA[
function ToggleMenu(itemName)
{
var elm = document.getElementById(itemName);
var i,others = document.getElementById('SectionMenu');
for(i=0; i < others.childNodes.length; i++)
{
var other = others.childNodes[i];
if ((other.className == 'MenuSectionBlock') && (other != elm))
other.style.display='none';
}
if (elm.style.display == 'block') elm.style.display='none';
else elm.style.display='block';
return false;
}
//]]></script>
<script type="text/javascript" language="Javascript" src="MoneyTypeForCLR.aspx_files/addto.js"></script>
<script type="text/javascript" language="Javascript">//<![CDATA[
function MarkAns(MemberID,MsgID,QID) {
document.write(unescape("%3Cdiv class=\"CallOut\"%3E"));
document.write("Was this a good answer to your question? ");
document.write(unescape("%3Ca href=\"#xx" + MsgID.toString() + "xx\" "));
document.write("onclick=\"RateMsg("+MemberID.toString()+", "+MsgID.toString()+",6,"+QID.toString()+");\"");
document.write(unescape("%3E"));
document.write(unescape("%3Cimg height=\"20\" width=\"20\" src=\"/script/Forums/Images/good.png\" alt=\"correct\" border=\"0\" align=\"absmiddle\" /%3E Yes%3C/a%3E"));
document.write(unescape("%3Ca href=\"#xx" + MsgID.toString() + "xx\" "));
document.write("onclick=\"RateMsg("+MemberID.toString()+","+MsgID.toString()+",7,"+QID.toString()+");\"");
document.write(unescape("%3E"));
document.write(unescape("%3Cimg height=\"20\" width=\"20\" src=\"/script/Forums/Images/bad.png\" alt=\"correct\" style=\"margin-left:10px\" border=\"0\" align=\"absmiddle\" /%3E No%3C/a%3E"));
document.write(unescape("%3C/div%3E"));
}
function MsgVFrm(MemberID,MsgID,GB,gp,bp,mt){
if(!GB)document.write("Rate this message: ");
document.write(unescape("%3Ca href=\"#xx" + MsgID.toString() + "xx\" onclick=\"RateMsg(" + MemberID.toString() + ", " + MsgID.toString() + ","));document.write((GB?"5":"1")+unescape(",0);\"%3E"));
if(GB) document.write(unescape("%3Cimg height=\"20\" width=\"20\" src=\"/script/Forums/Images/good.png\" alt=\"good\" border=\"0\" align=\"absmiddle\" /%3E "+gp+" "+mt+"%3C/a%3E "));
else document.write(unescape("%3Cimg height=\"14\" width=\"14\" src=\"/script/Forums/Images/thumbs_down.gif\" alt=\"vote 1\" border=\"0\" align=\"middle\" /%3E%3C/a%3E "));
if(GB)document.write(" "); else for(var i=1; i<=5;i++)
document.write(unescape("%3Ca class=\"Frm_MHL\" href=\"#xx" + MsgID.toString() + "xx\" title=\"vote this message a " + i.toString() + "\" onclick=\"RateMsg(" + MemberID.toString() + ", " + MsgID.toString() + ", " + i.toString() + ",0)\"%3E%3Cb%3E" + i.toString() + "%3C/b%3E%3C/a%3E "));
document.write(unescape("%3Ca href=\"#xx" + MsgID.toString() + "xx\" onclick=\"RateMsg(" + MemberID.toString() + ", " + MsgID.toString() + ","));document.write((GB?"1":"5")+unescape(",0);\"%3E"));
if(GB)document.write(unescape("%3Cimg height=\"20\" width=\"20\" src=\"/script/Forums/Images/bad.png\" alt=\"bad\" border=\"0\" align=\"absmiddle\" /%3E "+bp+" "+mt+"%3C/a%3E"));
else document.write(unescape("%3Cimg height=\"14\" width=\"14\" src=\"/script/Forums/Images/thumbs_up.gif\" border=\"0\" alt=\"vote 5\" align=\"middle\" /%3E%3C/a%3E "));
}
function ReportMsg(userid, msgid, score) {
if (confirm("Are you sure you want to report this message?"))
return RateMsg(userid, msgid, score, 0);
else return false;
}
function RateMsg(memberid, msgid, score, questionId) {
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (req.readyState == 4){
if (req.status == 200){
var respText = req.responseText;
var re = new RegExp(unescape("\%3Cdiv\%3E([^\%3C]*)\%3C/div\%3E"), "g");
var match = re.exec(respText);
voteStatus.innerHTML = unescape("%3Cb%3E") + (match&&match[1])?match[1]:"An error occured" + unescape("%3C/b%3E");
} else
voteStatus.innerHTML = unescape("%3Cb style='color:red'%3EFailed!") + req.statusText + unescape("%3C/b%3E");
}
}
var voteStatus = document.getElementById("MVF" + msgid);
if (!voteStatus) return;
voteStatus.innerHTML = unescape("%3Cb style='color:green'%3EVoting...%3C/b%3E");
var strAction = "/script/Forums/Vote.aspx?js=1&fmid="+memberid.toString()+"&select="+msgid.toString()+"&score="+score.toString()+"&qid="+questionId.toString();
req.open("GET", strAction, true);
req.send(null);
return false;
}
//]]></script>
<script type="text/javascript" language="Javascript">//<![CDATA[
var S