<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2" -->
<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/"
	>

<channel>
	<title>www.giannistsakiris.com</title>
	<link>http://www.giannistsakiris.com</link>
	<description>mostly computer related stuff</description>
	<pubDate>Sat, 09 Jan 2010 10:08:26 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2</generator>
	<language>en</language>
			<item>
		<title>Base-2 and Base-N logarithm calculation in Java</title>
		<link>http://www.giannistsakiris.com/index.php/2010/01/09/base-2-and-base-n-logarithm-calculation-in-java/</link>
		<comments>http://www.giannistsakiris.com/index.php/2010/01/09/base-2-and-base-n-logarithm-calculation-in-java/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 10:08:26 +0000</pubDate>
		<dc:creator>giannis</dc:creator>
		
		<category><![CDATA[uncategorized]]></category>

		<guid isPermaLink="false">https://www.giannistsakiris.com/index.php/2010/01/09/base-2-and-base-n-logarithm-calculation-in-java/</guid>
		<description><![CDATA[I was surprised today to see that the Math package does not provide a method that the calculation of an arbitrary base logarithm, even though it provides a log10() method for base-10 logarithms.

One can easily calculate the logarithm of any base using the following simple equation:



Where logk is the function that returns the base-k logarithm [...]]]></description>
			<content:encoded><![CDATA[I was surprised today to see that the Math package does not provide a method that the calculation of an arbitrary base logarithm, even though it provides a log10() method for base-10 logarithms.<br/>
<br/>
One can easily calculate the logarithm of any base using the following simple equation:<br/>
<br/>
<img src="https://www.giannistsakiris.com/wp-content/uploads/2010/01/log.png" alt="log.png" /><br/>
<br/>
Where log<em>k</em> is the function that returns the base-k logarithm of a number, and it can be any real number.<br/>
<br/>
In terms of Java it can be written like this:<br/>
<blockquote> public class Logarithm<br/>
{<br/>
public static double logb( double a, double b )<br/>
{<br/>
return Math.log(a) / Math.log(b);<br/>
}<br/>
<br/>
public static double log2( double a )<br/>
{<br/>
return logb(a,2);<br/>
}<br/>
<br/>
public static void main( String[] args )<br/>
{<br/>
System.out.println(log2(100));<br/>
}<br/>
}</blockquote>]]></content:encoded>
			<wfw:commentRss>http://www.giannistsakiris.com/index.php/2010/01/09/base-2-and-base-n-logarithm-calculation-in-java/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
