<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" 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/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Nick Berardi's Coder Journal</title>
	
	<link>http://coderjournal.com</link>
	<description>My journal.</description>
	<lastBuildDate>Tue, 22 May 2012 17:00:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/coderjournal" /><feedburner:info uri="coderjournal" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><creativeCommons:license>http://creativecommons.org/licenses/by-sa/3.0/</creativeCommons:license><image><link>http://creativecommons.org/licenses/by-sa/3.0/</link><url>http://creativecommons.org/images/public/somerights20.gif</url><title>Some Rights Reserved</title></image><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/coderjournal" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.plusmo.com/add?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare href="http://www.wikio.com/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Ffeeds.feedburner.com%2Fcoderjournal" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><item>
		<title>Setting Up A GitHub Specific PowerShell Profile</title>
		<link>http://feedproxy.google.com/~r/coderjournal/~3/pvk668s5z34/</link>
		<comments>http://coderjournal.com/2012/05/setting-up-a-github-specific-powershell-profile/#comments</comments>
		<pubDate>Tue, 22 May 2012 17:00:06 +0000</pubDate>
		<dc:creator>Nick Berardi</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://coderjournal.com/?p=1574</guid>
		<description><![CDATA[I was very excited to see that after several months of work Phil and Paul finally released their much talked about GitHub client for Windows. It has a great Metro style, and is very fluid and functional.  Here is an example of what my client looks like As you can see it is very clean, and [...]]]></description>
			<content:encoded><![CDATA[<p>I was very excited to see that after several months of work <a href="http://haacked.com">Phil</a> and <a href="http://blog.paulbetts.org/">Paul</a> finally <a href="https://github.com/blog/1127-github-for-windows">released</a> their much talked about <a href="http://windows.github.com">GitHub client for Windows</a>. It has a great Metro style, and is very fluid and functional.  Here is an example of what my client looks like</p>
<p><img title="GitHub Client" src="http://coderjournal.com/uploads/2012/05/GitHub-Client.png" alt="" /></p>
<p>As you can see it is very clean, and there are no typical windows borders or title bar which is common for Metro styled apps. As I was exploring the app, I stumbled on the fact that if you are using PowerShell as your default shell.</p>
<p><img class="alignnone size-full wp-image-1576" title="GitHub Client Default Console" src="http://coderjournal.com/uploads/2012/05/GitHub-Client-Default-Console.png" alt="" width="467" height="195" /></p>
<p>You can actually customize the PowerShell profile used by the app to be different and separate from your default Windows PowerShell profile. This can be useful if you want to install a separate set of modules or configure it in a different way than your default Windows PowerShell profile. To do this you create the PowerShell profile in the following path.</p>
<p><em>%USERPROFILE%\Documents\WindowsPowerShell\GitHub.PowerShell_profile.ps1</em></p>
<p>Here is how I configured my GitHub specific PowerShell profile.</p>
<pre class="brush: bash;">###############################################################################
# global variables
###############################################################################
$profileDir = [System.IO.Path]::GetDirectoryName($profile)

###############################################################################
# Set up a simple prompt, adding the git prompt parts inside git repos
###############################################################################
function prompt {
    $realLASTEXITCODE = $LASTEXITCODE

    Write-Host

    # Reset color, which can be messed up by Enable-GitColors
    $Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor

    Write-VcsStatus

    Write-Host($pwd) -ForegroundColor Green

    $global:LASTEXITCODE = $realLASTEXITCODE

    return "$ "
}

###############################################################################
# Exposes the environment vars in a batch and sets them in this PS session
###############################################################################
function Get-Batchfile($file)
{
    $theCmd = "`"$file`" &#038; set"
    cmd /c $theCmd | Foreach-Object {
        $thePath, $theValue = $_.split('=')
        Set-Item -path env:$thePath -value $theValue
    }
}

###############################################################################
# Sets the VS variables for this PS session to use
###############################################################################
function VsVars32($version = "10.0")
{
    $theKey = "HKLM:SOFTWARE\Microsoft\VisualStudio\" + $version
    $theVsKey = get-ItemProperty $theKey
    $theVsInstallPath = [System.IO.Path]::GetDirectoryName($theVsKey.InstallDir)
    $theVsToolsDir = [System.IO.Path]::GetDirectoryName($theVsInstallPath)
    $theVsToolsDir = [System.IO.Path]::Combine($theVsToolsDir, "Tools")
    $theBatchFile = [System.IO.Path]::Combine($theVsToolsDir, "vsvars32.bat")
    Get-Batchfile $theBatchFile
    [System.Console]::Title = "Visual Studio " + $version + " Windows Powershell"
}

###############################################################################
# aliases
###############################################################################

set-alias wide   format-wide

###############################################################################
# functions
###############################################################################

set-content function:\mklink "cmd /c mklink `$args"

###############################################################################
# setup posh-git
###############################################################################

Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)

# add Git to PATH
$env:path += ";" + (Get-Item "Env:ProgramFiles(x86)").Value + "\Git\bin"

# import posh-git
Import-Module posh-git

# customize git prompt display settings
$global:GitPromptSettings.BeforeText = '['
$global:GitPromptSettings.AfterText = '] '
$global:GitPromptSettings.BranchAheadForegroundColor = [ConsoleColor]::DarkGreen
$global:GitPromptSettings.WorkingForegroundColor = [ConsoleColor]::Magenta
$global:GitPromptSettings.UntrackedForegroundColor = [ConsoleColor]::Magenta

# set TERM to cygwin
Enable-GitColors

Pop-Location

Start-SshAgent -Quiet</pre>
<p>Let me know your configuration and any tips  you have about the new GitHub app.  A big thanks should be given to Phil and Paul for making our lives better.</p>
<img src="http://feeds.feedburner.com/~r/coderjournal/~4/pvk668s5z34" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coderjournal.com/2012/05/setting-up-a-github-specific-powershell-profile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://coderjournal.com/2012/05/setting-up-a-github-specific-powershell-profile/</feedburner:origLink></item>
		<item>
		<title>Using Git Bash in Console2</title>
		<link>http://feedproxy.google.com/~r/coderjournal/~3/n7fWSH-qpcI/</link>
		<comments>http://coderjournal.com/2012/05/using-git-bash-in-console2/#comments</comments>
		<pubDate>Tue, 22 May 2012 00:48:03 +0000</pubDate>
		<dc:creator>Nick Berardi</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://coderjournal.com/?p=1570</guid>
		<description><![CDATA[After reading Scott Hansleman&#8217;s post about Console2 I decided to give it a try full time. Overall I have to say I am very impressed and have no intention on switching back. It really is an impressive application, so if you are interested in trying something different, go to Scott&#8217;s post and follow his directions on [...]]]></description>
			<content:encoded><![CDATA[<p>After reading <a href="http://www.hanselman.com/blog/Console2ABetterWindowsCommandPrompt.aspx">Scott Hansleman&#8217;s post</a> about <a href="http://sourceforge.net/projects/console/">Console2</a> I decided to give it a try full time. Overall I have to say I am very impressed and have no intention on switching back. It really is an impressive application, so if you are interested in trying something different, go to Scott&#8217;s post and follow his directions on setting it up.</p>
<p>As a long time <a href="http://code.google.com/p/msysgit/">mysysgit</a> user for all my Git source control needs, I decided to find out if I could marry the two together to create a nice intersection between Console2 and msysgit&#8217;s Bash client.  And after a bit of searching and stumbling on <a href="http://coderjournal.com/2011/03/adding-git-command-line-to-visual-studio/">my own post </a>about setting up the bash client in Visual Studio, I answered my own question on how to set it up for Console2.  Here is what I cam up with:</p>
<ul>
<li><strong>Title:</strong> Git Bash</li>
<li><strong>Icon:</strong> C:\Program Files (x86)\Git\etc\git.ico</li>
<li><strong>Shell:</strong> C:\Windows\SysWOW64\cmd.exe /c &#8220;&#8221;C:\Program Files (x86)\Git\bin\sh.exe&#8221; &#8211;login -i&#8221;</li>
</ul>
<p><img title="Console2" src="http://coderjournal.com/uploads/2012/05/Console2.png" alt="" width="547" height="560" /></p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/coderjournal/~4/n7fWSH-qpcI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coderjournal.com/2012/05/using-git-bash-in-console2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://coderjournal.com/2012/05/using-git-bash-in-console2/</feedburner:origLink></item>
		<item>
		<title>Philly.NET: Scott Hanselman: The Future of ASP.NET</title>
		<link>http://feedproxy.google.com/~r/coderjournal/~3/RJS3m3cNi34/</link>
		<comments>http://coderjournal.com/2012/05/philly-net-scott-hanselman-the-future-of-asp-net/#comments</comments>
		<pubDate>Thu, 17 May 2012 12:20:44 +0000</pubDate>
		<dc:creator>Nick Berardi</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[philly.net]]></category>

		<guid isPermaLink="false">http://coderjournal.com/?p=1564</guid>
		<description><![CDATA[How Do I Sign Up You can signup here: http://phillydotnet20120531.eventbrite.com/ The Event May 31 Scott Hanselman: The Future of ASP.NET Thursday Blue Bell, PA This special meeting will be held at the Montgomery County Community College Science Center Auditorium in Blue Bell, PA on Thursday, May 31 from 6:30-9:00.We have some great meetings lined up for the [...]]]></description>
			<content:encoded><![CDATA[<h3>How Do I Sign Up</h3>
<p>You can signup here: <a href="http://phillydotnet20120531.eventbrite.com/">http://phillydotnet20120531.eventbrite.com/</a></p>
<h3>The Event</h3>
<table border="1" cellspacing="0" cellpadding="4">
<tbody>
<tr>
<td>May 31</td>
<td>Scott Hanselman: The Future of ASP.NET</td>
</tr>
<tr>
<td>Thursday Blue Bell, PA</td>
<td>This special meeting will be held at the Montgomery County Community College <a href="http://www.mc3.edu/aboutus/directions/cc-m.aspx">Science Center Auditorium</a> in Blue Bell, PA on Thursday, May 31 from 6:30-9:00.We have some great meetings lined up for the next few months. Please take a look at the upcoming schedule on the <a href="http://phillydotnet.org/">web site</a> and follow other local user groups on our <a href="http://www.phillydotnet.org/Lists/Communities/calendar.aspx">community calendar</a>.</td>
</tr>
<tr>
<td>6:30</td>
<td>Scott Hanselman, Microsoft <strong>The Future of ASP.NET 8</strong></td>
</tr>
<tr>
<td><img src="http://www.phillydotnet.org/Pictures/speakers/scotthanselman.jpg" alt="Scott Hanselman, Microsoft" /><img src="http://codecamp.phillydotnet.org/2012-1/Pictures/apprenda.jpg" alt="Apprenda Software" /></td>
<td>Spend a night with Scott and learn about the future of ASP.NET.<strong>Scott Hanselman</strong> works for Microsoft as Principal Community Architect for Web Platform and Tools, aiming to spread the good word about developing software, most often on the Microsoft stack. Before this he was the Chief Architect at Corillian Corporation, now a part of Checkfree, for 6+ years and before that he was a Principal Consultant at STEP Technology for nearly 7 years. He was also involved in a few things Microsoft-related like the MVP and RD programs and will speak about computers (and other passions) whenever someone will listen to him. He&#8217;s written in a few books, most recently with Bill Evjen and Devin Rader on Professional ASP.NET. He blogs at<a href="http://www.hanselman.com/">http://www.hanselman.com</a> for the last 10 years and podcasts weekly at <a href="http://www.hanselminutes.com/">http://www.hanselminutes.com</a> and <a href="http://www.thisdeveloperslife.com/">http://www.thisdeveloperslife.com</a>.We are pleased to have <strong>Apprenda Software</strong> as our sponsor for this event:Apprenda is an Open Platform-as-a-Service (PaaS) stack for .NET that enables any organization to transform their existing infrastructure into a self-service cloud application platform. By decoupling applications from infrastructure and Developers from IT, Apprenda empowers organizations to achieve significant cost savings and massive productivity improvements that result in better business/IT alignment.</p>
<p>Come enjoy the company of the best geeks in the Delaware Valley!</td>
</tr>
<tr>
<td>9:00</td>
<td>Books, software, and other goodies!</td>
</tr>
</tbody>
</table>
<img src="http://feeds.feedburner.com/~r/coderjournal/~4/RJS3m3cNi34" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coderjournal.com/2012/05/philly-net-scott-hanselman-the-future-of-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://coderjournal.com/2012/05/philly-net-scott-hanselman-the-future-of-asp-net/</feedburner:origLink></item>
		<item>
		<title>Metro on Windows 8 – Illegal characters in path</title>
		<link>http://feedproxy.google.com/~r/coderjournal/~3/VvF_m6JJwEc/</link>
		<comments>http://coderjournal.com/2012/05/metro-on-windows-8-illegal-characters-in-path/#comments</comments>
		<pubDate>Tue, 15 May 2012 17:27:58 +0000</pubDate>
		<dc:creator>Nick Berardi</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[Windows 8]]></category>
		<category><![CDATA[WinJS]]></category>

		<guid isPermaLink="false">http://coderjournal.com/?p=1562</guid>
		<description><![CDATA[As I was developing my first Metro App today I came upon this weird error. Error 1 Error : DEP0600 : The following unexpected error occurred during deployment: Illegal characters in path. at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional) at System.IO.Path.Combine(String path1, String path2) at Microsoft.VisualStudio.ImmersiveProjectServices.Shared.AppxLayoutManager.CheckPackageLayoutState(DeployPackageName deployPackageName, String location) at Microsoft.VisualStudio.ImmersiveProjectServices.Shared.LocalDeployJob.GetLayoutState(DeployPackageName deployName, Boolean hasFrameworkDependencies) at Microsoft.VisualStudio.ImmersiveProjectServices.Shared.RegisterAppxLayout.Start(Boolean forceNewLayout, [...]]]></description>
			<content:encoded><![CDATA[<p>As I was developing my first Metro App today I came upon this weird error.  </p>
<pre class="brush: text">Error	1	Error : DEP0600 : The following unexpected error occurred during deployment:
Illegal characters in path.
   at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
   at System.IO.Path.Combine(String path1, String path2)
   at Microsoft.VisualStudio.ImmersiveProjectServices.Shared.AppxLayoutManager.CheckPackageLayoutState(DeployPackageName deployPackageName, String location)
   at Microsoft.VisualStudio.ImmersiveProjectServices.Shared.LocalDeployJob.GetLayoutState(DeployPackageName deployName, Boolean hasFrameworkDependencies)
   at Microsoft.VisualStudio.ImmersiveProjectServices.Shared.RegisterAppxLayout.Start(Boolean forceNewLayout, Boolean forceRegistration, NetworkLoopbackState desiredNetworkLoopbackState, Boolean refreshLayoutOnly, String&#038; packageMoniker, String&#038; firstUserAppID, Exception&#038; deployException)</pre>
<p>Not knowing what to do, because the error is vague and cryptic. I decided to throw a hail mary pass and remove the application I was developing from the start menu.  And lo and behold this was the problem.  I know this is still a beta framework and everything, but can the Windows team please throw us a bone and put in exceptions that actually mean something.</p>
<h3>tl;dr</h3>
<p>Just uninstall the application you are developing from the start menu.</p>
<img src="http://feeds.feedburner.com/~r/coderjournal/~4/VvF_m6JJwEc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coderjournal.com/2012/05/metro-on-windows-8-illegal-characters-in-path/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://coderjournal.com/2012/05/metro-on-windows-8-illegal-characters-in-path/</feedburner:origLink></item>
		<item>
		<title>BigDecimal type in .NET</title>
		<link>http://feedproxy.google.com/~r/coderjournal/~3/f_8-3gr04WA/</link>
		<comments>http://coderjournal.com/2012/05/bigdecimal-type-in-net/#comments</comments>
		<pubDate>Mon, 14 May 2012 08:00:51 +0000</pubDate>
		<dc:creator>Nick Berardi</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[BigDecimal]]></category>
		<category><![CDATA[BigInteger]]></category>
		<category><![CDATA[Fluent Cassandra]]></category>

		<guid isPermaLink="false">http://coderjournal.com/?p=1556</guid>
		<description><![CDATA[Similar to the situation I previously posted about in my last blog entry on ZLIB Compression in .NET. I needed to support a byte array coming from Java&#8217;s BigDecimal type. To understand why I can&#8217;t just use the decimal type in .NET you have to understand that BigDecimal is designed to scale way beyond typical [...]]]></description>
			<content:encoded><![CDATA[<p>Similar to the situation I previously posted about in my last blog entry on <a href="http://coderjournal.com/2012/05/zlib-compression-in-net/">ZLIB Compression in .NET</a>.  I needed to support a byte array coming from Java&#8217;s <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/math/BigDecimal.html">BigDecimal type</a>.  </p>
<p>To understand why I can&#8217;t just use the decimal type in .NET you have to understand that BigDecimal is designed to scale way beyond typical numbers that anybody would realistically use in their day to day programming.  And supporting one of these types as a standard type, would eat up much more memory than a typical programmer would want to use for a single number.  </p>
<p>Java&#8217;s BigDecimal can scale from a number that is as small as 1 byte to as many as 64 bytes.  When Java&#8217;s BigDecimal generates a byte array it can range from 5 bytes up to 68 bytes depending on the number being represented, with the last 4 bytes being an integer representing the number of decimal places in the number.</p>
<p>Here is what I came up with, which you can <a href="https://gist.github.com/2667136">also find on GitHub&#8217;s Gist</a>.</p>
<pre class="brush: csharp;">using System;
using System.Numerics;

///
<summary>
/// A crude implimentation of the essentials needed from Java's BigDecimal
/// </summary>

public struct BigDecimal
{
	private readonly BigInteger _unscaledValue;
	private readonly int _scale;

	public BigDecimal(byte[] value)
	{
		byte[] number = new byte[value.Length - 4];
		byte[] flags = new byte[4];

		Array.Copy(value, 0, number, 0, number.Length);
		Array.Copy(value, value.Length - 4, flags, 0, 4);

		_unscaledValue = new BigInteger(number);
		_scale = flags[0];
	}

	public static explicit operator decimal(BigDecimal value)
	{
		var scaleDivisor = BigInteger.Pow(new BigInteger(10), value._scale);
		var remainder = BigInteger.Remainder(value._unscaledValue, scaleDivisor);
		var scaledValue = BigInteger.Divide(value._unscaledValue, scaleDivisor);

		if (scaledValue > new BigInteger(Decimal.MaxValue))
			throw new ArgumentOutOfRangeException("value", "The value " + value._unscaledValue + " cannot fit into System.Decimal.");

		var leftOfDecimal = (decimal)scaledValue;
		var rightOfDecimal = ((decimal)remainder) / ((decimal)scaleDivisor);

		return leftOfDecimal + rightOfDecimal;
	}
}</pre>
<p>To understand why I had to create my own BigDecimal type, you have to understand that the .NET decimal type always generates a byte array of 16 bytes, the first 12 being the integer, and the last 4 being the number of decimal places or the scale.  And because .NET always generates 16 bytes it assumes you are always going to read in 16 bytes, which is a bad assumption, but it is what it is.  And because of this 16 byte logic it brings me my problem.  I was having trouble reading in any number that didn&#8217;t produce exactly 16 bytes for the decimal from Java&#8217;s BigDecimal.  So I decided to create a very crude representation of the BigDecimal type in .NET.</p>
<p>I am putting this code out there, so nobody else has to hunt to find a solution to read in BigDecimal type from Java. Also there is a ton of room for expansion of this type, so if you do modify please let me know so I can update the gist.</p>
<img src="http://feeds.feedburner.com/~r/coderjournal/~4/f_8-3gr04WA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coderjournal.com/2012/05/bigdecimal-type-in-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://coderjournal.com/2012/05/bigdecimal-type-in-net/</feedburner:origLink></item>
	</channel>
</rss>

