Submitted On 09-JUN-1998
MartDesruisseaux
Need also pow10(x) to compute 10^x. It would be nice to have optimized code for
the case where x in pow10(x) is a small integer.
Submitted On 11-NOV-2002
bbatman
Why not make a general log(base, x) method that computes the
log in any base (> 0)?
Submitted On 12-NOV-2002
jddarcy
Once you have one logarithm in a given base, you can convert
that result into a log in a different base using the
relationship:
log_a(x) = log_b(x)/log_b(a) = log_b(x)*log_a(b)
For example,
log_10(x) = ln(x)/ln(10)
While this works fine mathematically, the extra
floating-point operations can introduce more error than you
would have from a single log10 function.
The bases e, 2, and 10 occur often enough that having
specialized log functions for these bases is warranted; for
other bases using the formula above should suffice.
Submitted On 06-NOV-2005
Why can't we have a single generic function log(x, b) which takes "base" b as an argument and evaluate log of a given value x to that base? rather than having three functions for ln, log2, and log10?
my two cents,
-Priyank.
Submitted On 02-MAY-2007
I fully agree with the commenter's opinions.
First and the most important argument is that of jddarcy, that additional floating point operations should be implemented within the library to allow centralized ( java core) optimalisations and tests of such features to evade prescision lost or bugs.
The second argument is according my opinion that most users forget the logarithm arithmetics ( as I did :)) and they expect the method usable to their task findable in the java.lang.Math api. The comment of such a method (log(double base, double x) could explain the arithmetic operations under the hood for the users to remain enlightened.
The final third argument is the one of 'why not' question.
thanx for replies
tomas r
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|