JDK-4074599 : Math package: implement log10 (base 10 logarithm)
  • Type: Enhancement
  • Status: Resolved
  • Resolution: Fixed
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P5
  • Affected Version: 1.1.3
  • OS: windows_95,windows_nt
  • CPU: x86
  • Submit Date: 1997-08-27
  • Updated Date: 2017-05-16
  • Resolved Date: 2003-05-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
Other
5.0 tigerResolved
Related Reports
Relates :  
Relates :  
Relates :  
Description

Name: tb29552			Date: 08/26/97


JDK 1.1 has Math.log which compute natural log values,
It would nice to include a method that compute log base 
10 value.
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b07
2004-06-14

WORK AROUND Log base 10 = Math.log(x)/Math.log(10) Log base 2 = Math.log(x)/Math.log(2) Name: tb29552 Date: 08/26/97 Given a number n greater than 0.0. Then the log10(n) is equal to ln(n)/ln(10) (where "ln()" is the natural logarithm (base e)) If you store ln(10) as a constant, then you can get the log10(n) from ln(n) with one additional divide. ====================================================================== tim.bell@Eng 1997-09-04 More generally: Given a number n greater than 0.0 and a number b greater than 0.0 Then the log<b>(n) is equal to ln(n)/ln(b) (where "ln()" is the natural logarithm (base e) and "log<b>()" is the log base b.)
2004-06-11

SUGGESTED FIX gative of the cube root of that value's magnitude. > * Special cases: > * > * <ul> > * > * <li>If the argument is NaN, then the result is NaN. > * > * <li>If the argument is infinite, then the result is an infinity > * with the same sign as the argument. > * > * <li>If the argument is zero, then the result is a zero with the > * same sign as the argument. > * > * </ul> > * > * @param a a value. > * @return the cube root of <code>a</code>. > * @since 1.5 > */ > public static native double cbrt(double a); > > /** 529,539c579,589 < * <p> < * When this method is first called, it creates a single new < * pseudorandom-number generator, exactly as if by the expression < * <blockquote><pre>new java.util.Random</pre></blockquote> < * This new pseudorandom-number generator is used thereafter for all < * calls to this method and is used nowhere else. < * <p> < * This method is properly synchronized to allow correct use by more < * than one thread. However, if many threads need to generate < * pseudorandom numbers at a great rate, it may reduce contention for < * each thread to have its own pseudorandom number generator. --- > * > * <p>When this method is first called, it creates a single new > * pseudorandom-number generator, exactly as if by the expression > * <blockquote><pre>new java.util.Random</pre></blockquote> This > * new pseudorandom-number generator is used thereafter for all > * calls to this method and is used nowhere else. > * > * <p>This method is properly synchronized to allow correct use by > * more than one thread. However, if many threads need to generate > * pseudorandom numbers at a great rate, it may reduce contention > * for each thread to have its own pseudorandom number generator. 554,558c604,608 < * <p> < * Note that if the argument is equal to the value of < * <code>Integer.MIN_VALUE</code>, the most negative representable < * <code>int</code> value, the result is that same value, which is < * negative. --- > * > * <p>Note that if the argument is equal to the value of > * <code>Integer.MIN_VALUE</code>, the most negative representable > * <code>int</code> value, the result is that same value, which is > * negative. 572,576c622,626 < * <p> < * Note that if the argument is equal to the value of < * <code>Long.MIN_VALUE</code>, the most negative representable < * <code>long</code> value, the result is that same value, which is < * negative. --- > * > * <p>Note that if the argument is equal to the value of > * <code>Long.MIN_VALUE</code>, the most negative representable > * <code>long</code> value, the result is that same value, which > * is negative. 778a829,923 > /** > * Returns the size of an ulp of the argument. An ulp of a > * <code>double</code> value is the positive distance between this > * floating-point value and the <code>double</code> value next > * larger in magnitude. Note that for non-NaN <i>x</i>, > * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>. > * > * <p>Special Cases: > * <ul> > * <li> If the argument is NaN, then the result is NaN. > * <li> If the argument is positive or negative infinity, then the > * result is positive infinity. > * <li> If the argument is positive or negative zero, then the result is > * <code>Double.MIN_VALUE</code>. > * <li> If the argument is &plusmn;<code>Double.MAX_VALUE</code>, then > * the result is equal to 2<sup>971</sup>. > * </ul> > * > * @param d the floating-point value whose ulp is to be returned > * @return the size of an ulp of the argument > * @author Joseph D. Darcy > * @since 1.5 > */ > public static double ulp(double d) { > return sun.misc.FpUtils.ulp(d); > } > > /** > * Returns the size of an ulp of the argument. An ulp of a > * <code>float</code> value is the positive distance between this > * floating-point value and the <code>float</code> value next > * larger in magnitude. Note that for non-NaN <i>x</i>, > * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>. > * > * <p>Special Cases: > * <ul> > * <li> If the argument is NaN, then the result is NaN. > * <li> If the argument is positive or negative infinity, then the > * result is positive infinity. > * <li> If the argument is positive or negative zero, then the result is > * <code>Float.MIN_VALUE</code>. > * <li> If the argument is &plusmn;<code>Float.MAX_VALUE</code>, then > * the result is equal to 2<sup>104</sup>. > * </ul> > * > * @param f the floating-point value whose ulp is to be returned > * @return the size of an ulp of the argument > * @author Joseph D. Darcy > * @since 1.5 > */ > public static float ulp(float f) { > return sun.misc.FpUtils.ulp(f); > } > > /** > * Returns the signum function of the argument; zero if the argument > * is zero, 1.0 if the argument is greater than zero, -1.0 if the > * argument is less than zero. > * > * <p>Special Cases: > * <ul> > * <li> If the argument is NaN, then the result is NaN. > * <li> If the argument is positive zero or negative zero, then the > * result is the same as the argument. > * </ul> > * > * @param d the floating-point value whose signum is to be returned > * @return the signum function of the argument > * @author Joseph D. Darcy > * @since 1.5 > */ > public static double signum(double d) { > return sun.misc.FpUtils.signum(d); > } > > /** > * Returns the signum function of the argument; zero if the argument > * is zero, 1.0f if the argument is greater than zero, -1.0f if the > * argument is less than zero. > * > * <p>Special Cases: > * <ul> > * <li> If the argument is NaN, then the result is NaN. > * <li> If the argument is positive zero or negative zero, then the > * result is the same as the argument. > * </ul> > * > * @param f the floating-point value whose signum is to be returned > * @return the signum function of the argument > * @author Joseph D. Darcy > * @since 1.5 > */ > public static float signum(float f) { > return sun.misc.FpUtils.signum(f); > }
2004-06-11

SUGGESTED FIX Directory make/java/java sccs sccsdiff -r1.51 -r1.52 mapfile-vers ------- mapfile-vers ------- 141a142 > Java_java_lang_StrictMath_log10; 145a147 > Java_java_lang_StrictMath_cbrt; Directory src/share/native/java/lang/fdlibm/include sccs sccsdiff -r1.8 -r1.9 jfdlibm.h ------- jfdlibm.h ------- 26a27 > #define log10 jlog10 29a31 > #define cbrt jcbrt Directory src/share/native/java/lang sccs sccsdiff -r1.51 -r1.52 StrictMath.c ------- StrictMath.c ------- 61a62,67 > Java_java_lang_StrictMath_log10(JNIEnv *env, jclass unused, jdouble d) > { > return (jdouble) jlog10((double)d); > } > > JNIEXPORT jdouble JNICALL 66a73,78 > JNIEXPORT jdouble JNICALL > Java_java_lang_StrictMath_cbrt(JNIEnv *env, jclass unused, jdouble d) > { > return (jdouble) jcbrt((double)d); > } > Directory src/share/classes/java/lang ------- Math.java ------- 4c4 < * Copyright 2003 Sun Microsystems, Inc. All rights reserved. --- > * Copyright 2002 Sun Microsystems, Inc. All rights reserved. 16,17c16,17 < * <p> < * Unlike some of the numeric methods of class --- > * > * <p>Unlike some of the numeric methods of class 23,24c23,24 < * <p> < * By default many of the <code>Math</code> methods simply call --- > * > * <p>By default many of the <code>Math</code> methods simply call 32,33c32,33 < * <p> < * The quality of implementation specifications concern two --- > * > * <p>The quality of implementation specifications concern two 93,95c93,95 < * <p> < * A result must be within 1 ulp of the correctly rounded result. Results < * must be semi-monotonic. --- > * > * <p>A result must be within 1 ulp of the correctly rounded > * result. Results must be semi-monotonic. 108,110c108,110 < * <p> < * A result must be within 1 ulp of the correctly rounded result. Results < * must be semi-monotonic. --- > * > * <p>A result must be within 1 ulp of the correctly rounded > * result. Results must be semi-monotonic. 125,127c125,127 < * <p> < * A result must be within 1 ulp of the correctly rounded result. Results < * must be semi-monotonic. --- > * > * <p>A result must be within 1 ulp of the correctly rounded > * result. Results must be semi-monotonic. 143,145c143,145 < * <p> < * A result must be within 1 ulp of the correctly rounded result. Results < * must be semi-monotonic. --- > * > * <p>A result must be within 1 ulp of the correctly rounded > * result. Results must be semi-monotonic. 159,161c159,161 < * <p> < * A result must be within 1 ulp of the correctly rounded result. Results < * must be semi-monotonic. --- > * > * <p>A result must be within 1 ulp of the correctly rounded > * result. Results must be semi-monotonic. 176,178c176,178 < * <p> < * A result must be within 1 ulp of the correctly rounded result. Results < * must be semi-monotonic. --- > * > * <p>A result must be within 1 ulp of the correctly rounded > * result. Results must be semi-monotonic. 225,227c225,227 < * <p> < * A result must be within 1 ulp of the correctly rounded result. Results < * must be semi-monotonic. --- > * > * <p>A result must be within 1 ulp of the correctly rounded > * result. Results must be semi-monotonic. 246,248c246,248 < * <p> < * A result must be within 1 ulp of the correctly rounded result. Results < * must be semi-monotonic. --- > * > * <p>A result must be within 1 ulp of the correctly rounded > * result. Results must be semi-monotonic. 250c250 < * @param a a number greater than <code>0.0</code>. --- > * @param a a value 258a259,283 > * Returns the base 10 logarithm of a <code>double</code> value. > * Special cases: > * > * <ul><li>If the argument is NaN or less than zero, then the result > * is NaN. > * <li>If the argument is positive infinity, then the result is > * positive infinity. > * <li>If the argument is positive zero or negative zero, then the > * result is negative infinity. > * <li> If the argument is equal to 10<sup><i>n</i></sup> for > * integer <i>n</i>, then the result is <i>n</i>. > * </ul> > * > * <p>A result must be within 1 ulp of the correctly rounded > * result. Results must be semi-monotonic. > * > * @param a a value > * @return the base 10 logarithm of <code>a</code>. > * @since 1.5 > */ > public static double log10(double a) { > return StrictMath.log10(a); // default impl. delegates to StrictMath > } > > /** 283a309 > 284a311,340 > * Returns the cube root of a <code>double</code> value. For > * positive finite <code>x</code>, <code>cbrt(-x) == > * -cbrt(x)</code>; that is, the cube root of a negative value is > * the negative of the cube root of that value's magnitude. > * > * Special cases: > * > * <ul> > * > * <li>If the argument is NaN, then the result is NaN. > * > * <li>If the argument is infinite, then the result is an infinity > * with the same sign as the argument. > * > * <li>If the argument is zero, then the result is a zero with the > * same sign as the argument. > * > * </ul> > * > * A result must be within 1 ulp of the correctly rounded result. > * > * @param a a value. > * @return the cube root of <code>a</code>. > * @since 1.5 > */ > public static double cbrt(double a) { > return StrictMath.cbrt(a); > } > > /** 411,413c467,469 < * <p> < * A result must be within 2 ulps of the correctly rounded result. Results < * must be semi-monotonic. --- > * > * <p>A result must be within 2 ulps of the correctly rounded > * result. Results must be semi-monotonic. 618,628c674,684 < * <p> < * When this method is first called, it creates a single new < * pseudorandom-number generator, exactly as if by the expression < * <blockquote><pre>new java.util.Random</pre></blockquote> < * This new pseudorandom-number generator is used thereafter for all < * calls to this method and is used nowhere else. < * <p> < * This method is properly synchronized to allow correct use by more < * than one thread. However, if many threads need to generate < * pseudorandom numbers at a great rate, it may reduce contention for < * each thread to have its own pseudorandom-number generator. --- > * > * <p>When this method is first called, it creates a single new > * pseudorandom-number generator, exactly as if by the expression > * <blockquote><pre>new java.util.Random</pre></blockquote> This > * new pseudorandom-number generator is used thereafter for all > * calls to this method and is used nowhere else. > * > * <p>This method is properly synchronized to allow correct use by > * more than one thread. However, if many threads need to generate > * pseudorandom numbers at a great rate, it may reduce contention > * for each thread to have its own pseudorandom-number generator. 643,647c699,703 < * <p> < * Note that if the argument is equal to the value of < * <code>Integer.MIN_VALUE</code>, the most negative representable < * <code>int</code> value, the result is that same value, which is < * negative. --- > * > * <p>Note that if the argument is equal to the value of > * <code>Integer.MIN_VALUE</code>, the most negative representable > * <code>int</code> value, the result is that same value, which is > * negative. 661,665c717,721 < * <p> < * Note that if the argument is equal to the value of < * <code>Long.MIN_VALUE</code>, the most negative representable < * <code>long</code> value, the result is that same value, which is < * negative. --- > * > * <p>Note that if the argument is equal to the value of > * <code>Long.MIN_VALUE</code>, the most negative representable > * <code>long</code> value, the result is that same value, which > * is negative. 867a924,1018 > /** > * Returns the size of an ulp of the argument. An ulp of a > * <code>double</code> value is the positive distance between this > * floating-point value and the <code>double</code> value next > * larger in magnitude. Note that for non-NaN <i>x</i>, > * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>. > * > * <p>Special Cases: > * <ul> > * <li> If the argument is NaN, then the result is NaN. > * <li> If the argument is positive or negative infinity, then the > * result is positive infinity. > * <li> If the argument is positive or negative zero, then the result is > * <code>Double.MIN_VALUE</code>. > * <li> If the argument is &plusmn;<code>Double.MAX_VALUE</code>, then > * the result is equal to 2<sup>971</sup>. > * </ul> > * > * @param d the floating-point value whose ulp is to be returned > * @return the size of an ulp of the argument > * @author Joseph D. Darcy > * @since 1.5 > */ > public static double ulp(double d) { > return sun.misc.FpUtils.ulp(d); > } > > /** > * Returns the size of an ulp of the argument. An ulp of a > * <code>float</code> value is the positive distance between this > * floating-point value and the <code>float</code> value next > * larger in magnitude. Note that for non-NaN <i>x</i>, > * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>. > * > * <p>Special Cases: > * <ul> > * <li> If the argument is NaN, then the result is NaN. > * <li> If the argument is positive or negative infinity, then the > * result is positive infinity. > * <li> If the argument is positive or negative zero, then the result is > * <code>Float.MIN_VALUE</code>. > * <li> If the argument is &plusmn;<code>Float.MAX_VALUE</code>, then > * the result is equal to 2<sup>104</sup>. > * </ul> > * > * @param f the floating-point value whose ulp is to be returned > * @return the size of an ulp of the argument > * @author Joseph D. Darcy > * @since 1.5 > */ > public static float ulp(float f) { > return sun.misc.FpUtils.ulp(f); > } > > /** > * Returns the signum function of the argument; zero if the argument > * is zero, 1.0 if the argument is greater than zero, -1.0 if the > * argument is less than zero. > * > * <p>Special Cases: > * <ul> > * <li> If the argument is NaN, then the result is NaN. > * <li> If the argument is positive zero or negative zero, then the > * result is the same as the argument. > * </ul> > * > * @param d the floating-point value whose signum is to be returned > * @return the signum function of the argument > * @author Joseph D. Darcy > * @since 1.5 > */ > public static double signum(double d) { > return sun.misc.FpUtils.signum(d); > } > > /** > * Returns the signum function of the argument; zero if the argument > * is zero, 1.0f if the argument is greater than zero, -1.0f if the > * argument is less than zero. > * > * <p>Special Cases: > * <ul> > * <li> If the argument is NaN, then the result is NaN. > * <li> If the argument is positive zero or negative zero, then the > * result is the same as the argument. > * </ul> > * > * @param f the floating-point value whose signum is to be returned > * @return the signum function of the argument > * @author Joseph D. Darcy > * @since 1.5 > */ > public static float signum(float f) { > return sun.misc.FpUtils.signum(f); > } ------- StrictMath.java ------- 4c4 < * Copyright 2003 Sun Microsystems, Inc. All rights reserved. --- > * Copyright 2002 Sun Microsystems, Inc. All rights reserved. 16,18c16,18 < * <p> < * To help ensure portability of Java programs, the definitions of < * many of the numeric functions in this package require that they --- > * > * <p>To help ensure portability of Java programs, the definitions of > * some of the numeric functions in this package require that they 26,27c26,27 < * <p> < * The network library may be found on the World Wide Web at: --- > * > * <p>The network library may be found on the World Wide Web at: 31,37c31,42 < * <p> < * The Java math library is defined with respect to the version of < * <code>fdlibm</code> dated January 4, 1995. Where < * <code>fdlibm</code> provides more than one definition for a < * function (such as <code>acos</code>), use the "IEEE 754 core < * function" version (residing in a file whose name begins with < * the letter <code>e</code>). --- > * > * <p>The Java math library is defined with respect to the version of > * <code>fdlibm</code> dated January 4, 1995. Where > * <code>fdlibm</code> provides more than one definition for a > * function (such as <code>acos</code>), use the "IEEE 754 core > * function" version (residing in a file whose name begins with the > * letter <code>e</code>). The methods which require > * <code>fdlibm</code> semantics are <code>sin</code>, > * <code>cos</code>, <code>tan</code>, <code>asin</code>, > * <code>acos</code>, <code>atan</code>, <code>exp</code>, > * <code>log</code>, <code>log10</code>, <code>cbrt</code>, > * <code>atan2</code>, and <code>pow</code>. 44c49 < public final strictfp class StrictMath { --- > public final class StrictMath { 187c192 < * @param a a number greater than <code>0.0</code>. --- > * @param a a value 192a198 > 193a200,219 > * Returns the base 10 logarithm of a <code>double</code> value. > * Special cases: > * > * <ul><li>If the argument is NaN or less than zero, then the result > * is NaN. > * <li>If the argument is positive infinity, then the result is > * positive infinity. > * <li>If the argument is positive zero or negative zero, then the > * result is negative infinity. > * <li> If the argument is equal to 10<sup><i>n</i></sup> for > * integer <i>n</i>, then the result is <i>n</i>. > * </ul> > * > * @param a a value > * @return the base 10 logarithm of <code>a</code>. > * @since 1.5 > */ > public static native double log10(double a); > > /** 207d232 < * <!--@return the value of &radic;&nbsp;<code>a</code>.--> 212a238,262 > * Returns the cube root of a <code>double</code> value. For > * positive finite <code>x</code>, <code>cbrt(-x) == > * -cbrt(x)</code>; that is, the cube root of a negative value is > * the ne
2004-06-11

EVALUATION Why was this missed in the first place? anand.palaniswamy@Eng 1997-11-05 The log10() is trivial to derive from the log(). log10(x) = log(x) / log(10). It does not worth the trouble to change the well-know Math class API. ###@###.### 1998-06-12 While trivial to compute, the log10 function is sufficiently common and useful that we should eventually provide it. It didn't make it into 1.2 because it was just too late; I'm reopening this so that it gets considered for the next feature release. -- mr@eng 6/12/1998 This is a library issue. ###@###.### 2000-06-29 I will try to get this method added in the next major Java release, 1.4. joe.darcy@eng 2001-06-25 Being considered as part of larger math library effort in 1.5. ###@###.### 2003-03-18
2001-06-25