<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>software, bourbon, and the banjo &#187; Uncategorized</title>
	<atom:link href="http://www.cansado.org/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cansado.org</link>
	<description>musings on software development, usually while inebriated</description>
	<lastBuildDate>Mon, 09 Jan 2012 02:13:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using Java&#8217;s BigInteger for Large Operations</title>
		<link>http://www.cansado.org/2009/12/01/using-javas-biginteger-for-large-operations/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-javas-biginteger-for-large-operations</link>
		<comments>http://www.cansado.org/2009/12/01/using-javas-biginteger-for-large-operations/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 04:56:39 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cansado.org/?p=66</guid>
		<description><![CDATA[Java&#8217;s BigInteger is a very handle tool to have in your toolbox as a ColdFusion programmer. If you&#8217;re ever in a situation where you need to do operations on large numbers (larger than a mere 32-bit Integer can handle) you&#8217;ll need to delve into BigInteger territory. For example, someone came into the #Coldfusion channel on [...]]]></description>
			<content:encoded><![CDATA[<p>Java&#8217;s <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html">BigInteger</a> is a very handle tool to have in your toolbox as a ColdFusion programmer. If you&#8217;re ever in a situation where you need to do operations on large numbers (larger than a mere 32-bit Integer can handle) you&#8217;ll need to delve into BigInteger territory.</p>
<p>For example, someone came into the #Coldfusion channel on freenode.net wanting to know why <code>InputBaseN("0x85A308d3", 16)</code> was giving a negative response. Well, that&#8217;s because most numeric operations in ColdFusion are performed on Integers, and the argument was sufficiently large enough to overflow the result into negative.</p>
<p>BigInteger to the rescue! Feast on this code:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;">  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> bigint <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">createObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;java&quot;</span>, <span style="color: #009900;">&quot;java.math.BigInteger&quot;</span><span style="color: #0000FF;">&#41;</span>.init<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;85A308d3&quot;</span>, <span style="color: #FF0000;">16</span><span style="color: #0000FF;">&#41;</span>.<span style="color: #0000FF;">toString</span><span style="color: #0000FF;">&#40;</span><span style="color: #FF0000;">10</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<p>Very simply, we&#8217;re creating a BigInteger with the value of 85A308D3 in hexadecimal (the 16 is called the <i>radix</i>) and then outputting it via <code>toString(10)</code> where the 10 is the radix for decimal.</p>
<p>Simple! And if you look at the Javadocs for BigInteger, you&#8217;ll see you can perform a whole slew of operations: addition, subtraction, modulo, xor, and, or, pow&#8230; almost any numeric operation.</p>
<p>So that&#8217;s 10 posts. Time for a celebratory bourbon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cansado.org/2009/12/01/using-javas-biginteger-for-large-operations/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
