Please anyone tell me the way of how find a logarithmic value(base 2) for a number in java

Printable View

- 07-03-2008, 02:06 PMRJNARESHHow to find logarithm base 2 value in java
Please anyone tell me the way of how find a logarithmic value(base 2) for a number in java

- 07-03-2008, 04:25 PMNorm
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-04-2008, 12:38 AMfishtoprecords
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, 02:09 PMjagjit_surfer@yahoo.comfing 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, 06:58 PMneilcoffey
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. - 03-19-2009, 11:12 PMFubarable
The zombies threads have arisen!