# How to Implement n-base logarithm

Page 1 of 1

## 3 Replies - 46275 Views - Last Post: 19 April 2010 - 02:53 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=16488&amp;s=189880cdff54b735018422593e0f173f&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 henryl

Reputation: 2
• Posts: 24
• Joined: 12-May 06

# How to Implement n-base logarithm

Posted 30 May 2006 - 09:34 AM

Hi.

I'm trying to generate random numbers with a Cellular Automata. For this, I implement a Genetic Algorithm which find the best rule for the Automata's cells. The Genetic Algorithm evaluate the rules, but it needs to use the two-base logarithm, and the lybrary math.h don't implement this function.

Does exist any library that implement n-base logarithm?

Thanks.
Is This A Good Question/Topic? 0

### #5 Nova Dragoon

• The Innocent Shall Suffer, Big Time

Reputation: 36
• Posts: 6,169
• Joined: 16-August 01

## Re: How to Implement n-base logarithm

Posted 30 May 2006 - 09:46 AM

you could use the dirty math hack to do change of log bases

its

logb (x) = (loga(x)) / (loga(B))
example

log base 2 (5) = (log base 10 (5) ) / (log base 10 (2) )

### #6 William_Wilson

• lost in compilation

Reputation: 207
• Posts: 4,812
• Joined: 23-December 05

## Re: How to Implement n-base logarithm

Posted 30 May 2006 - 10:36 AM

I don't think there is a library to do such a thing as the formula is not all that complex. There is a function in the math/h library to handle log and that is considered sufficient.

Reputation:

## Re: How to Implement n-base logarithm

Posted 19 April 2010 - 02:53 AM

Nova Dragoon, on 30 May 2006 - 08:46 AM, said:

you could use the dirty math hack to do change of log bases

its

logb (x) = (loga(x)) / (loga()
example

log base 2 (5) = (log base 10 (5) ) / (log base 10 (2) )

this code is correct.