Results 1 to 6 of 6
- 07-03-2008, 01:06 PM #1
Member
- Join Date
- Jul 2008
- Posts
- 1
- Rep Power
- 0
- 07-03-2008, 03:25 PM #2
Sounds like a math question. Give us the algorithm for computing log(base 2) and we'll help you write the code.
The Math class has several log methods.
- 07-03-2008, 11:38 PM #3
also, there are trivial conversions for a log in one base to another. Smells like homework, so I'll let you do some real work on it.
- 03-19-2009, 01:09 PM #4
Member
- Join Date
- Mar 2009
- Posts
- 1
- Rep Power
- 0
fing log base 2
log method of Math class gives us the natural logarithm of any given no. which is base e.
You can convert it to any base , let's say n, using the equation,
log x(base n)=log x(base e)/log n(base e)
- 03-19-2009, 05:58 PM #5
Senior Member
- Join Date
- Nov 2008
- Posts
- 286
- Rep Power
- 5
Note that in the special case where you want the integer logarithm of an integer value, then you can get it from the highest set bit (or number of leading zeroes) of that number's binary representation, which is generally quicker to find.
Neil Coffey
Javamex - Java tutorials and performance info
-
Similar Threads
-
[SOLVED] base directory for servlets
By Nicholas Jordan in forum Java ServletReplies: 11Last Post: 07-04-2008, 11:29 PM -
Problems with Jtable connected to data base
By elizabeth in forum AWT / SwingReplies: 2Last Post: 08-07-2007, 04:24 PM -
Problems when I try to connect to data base
By gabriel in forum JDBCReplies: 1Last Post: 08-06-2007, 05:38 PM -
2 threads sharing a data base connection
By Ed in forum Advanced JavaReplies: 2Last Post: 07-04-2007, 04:41 AM -
Connection to data base
By Daniel in forum JDBCReplies: 2Last Post: 06-07-2007, 04:55 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks