JDK-4323012 : Class java.lang.Math needs a logarithm function with base other than 'e'
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.2.2
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2000-03-17
  • Updated: 2003-07-29
  • Resolved: 2003-07-29
Related Reports
Relates :  
Description

Name: skT88420			Date: 03/17/2000


not necessary

The java.lang.Math.log() function only has log base 'e'. The function Math.log()
should take two parameters:

public double log( double a, int base );

in order to compensate for logarithms of other bases. a simple fix would be to
add

public double log( double a, int base ){
   return log( a ) / log( base );
}

to the Math class.

oh, and on the bug form, there needs to be an 'annoying missing feature' button.
(Review ID: 102613) 
======================================================================

Comments
WORK AROUND Name: skT88420 Date: 03/17/2000 a simple fix would be to add public double log( double a, int base ){ return log( a ) / log( base ); } to the Math class. ======================================================================
11-06-2004

EVALUATION There are only a few bases of real interest, 2, e, and 10. Log functions in those bases should be provided; logs in other bases can be approximated as suggested. joe.darcy@eng 2001-06-25 Bug 4074599 added a base-10 log to the math libraries. Bug 4851627 requests a base-2 log. With those methods, logs in other bases can be approximated using the given formula. Closing as will not fix. ###@###.### 2003-07-29
29-07-2003