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

Printable View

- 07-03-2008, 01: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, 03: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-03-2008, 11:38 PMfishtoprecords
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 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, 05: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, 10:12 PMFubarable
The zombies threads have arisen!