JDK-6221118 : java.util.Random.nextGaussian should specify StrictMath instead of Math methods
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 6
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-01-25
  • Updated: 2017-05-16
  • Resolved: 2005-02-05
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 Availability Release.

To download the current JDK release, click here.
JDK 6
6 b23Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
The class java.util.Random is intended to provide cross-platform bit-for-bit reproducability of random numbers.  However, the JavaDoc for the nextGaussian method is given in terms of Math.log; since 1.3 and the introduction of the StrictMath class, Math.log has not been required to get bitwise reproducible results across platforms.  Therefore, to maintain the original intended specification of nextGaussian, the specification should require StrictMath.log instead of Math.log.  (For clarity StrictMath.sqrt should be required instead of Math.sqrt although StrictMath.sqrt and Math.sqrt and defined, and required, to return the same results in all cases.)

The possible behavioral differences between Math.log and StrictMath was not a de facto issue until the recent intrinsification of log, 6196383.

###@###.### 2005-1-25 06:34:57 GMT
###@###.### 2005-1-25 06:52:16 GMT

Comments
EVALUATION A fine idea. ###@###.### 2005-1-25 06:34:57 GMT
25-01-2005

SUGGESTED FIX src/share/classes/java/util>sccs sccsdiff -r1.43 -r1.44 Random.java ------- Random.java ------- 396c396,397 < * <tt>nextGaussian</tt> is implemented by class <tt>Random</tt> as follows: --- > * <tt>nextGaussian</tt> is implemented by class <tt>Random</tt> as if > * by the following: 409c410 < * double multiplier = Math.sqrt(-2 * Math.log(s)/s); --- > * double multiplier = StrictMath.sqrt(-2 * StrictMath.log(s)/s); 419,420c420,421 < * independent values at the cost of only one call to <tt>Math.log</tt> < * and one call to <tt>Math.sqrt</tt>. --- > * independent values at the cost of only one call to <tt>StrictMath.log</tt> > * and one call to <tt>StrictMath.sqrt</tt>. 439c440 < double multiplier = Math.sqrt(-2 * Math.log(s)/s); --- > double multiplier = StrictMath.sqrt(-2 * StrictMath.log(s)/s); ###@###.### 2005-2-02 03:18:04 GMT
25-01-2005