hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r956697 - in /hadoop/mapreduce/trunk: CHANGES.txt src/examples/org/apache/hadoop/examples/QuasiMonteCarlo.java
Date Mon, 21 Jun 2010 21:18:58 GMT
Author: szetszwo
Date: Mon Jun 21 21:18:57 2010
New Revision: 956697

URL: http://svn.apache.org/viewvc?rev=956697&view=rev
Log:
MAPREDUCE-1880. Fix BigDecimal.divide(..) in the pi example.

Modified:
    hadoop/mapreduce/trunk/CHANGES.txt
    hadoop/mapreduce/trunk/src/examples/org/apache/hadoop/examples/QuasiMonteCarlo.java

Modified: hadoop/mapreduce/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/CHANGES.txt?rev=956697&r1=956696&r2=956697&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/CHANGES.txt (original)
+++ hadoop/mapreduce/trunk/CHANGES.txt Mon Jun 21 21:18:57 2010
@@ -1572,3 +1572,5 @@ Release 0.21.0 - Unreleased
 
     MAPREDUCE-1765. Correct streaming documentation for StreamXmlRecordReader.
     (Corinne Chandel via amareshwari)
+
+    MAPREDUCE-1880. Fix BigDecimal.divide(..) in the pi example.  (szetszwo)

Modified: hadoop/mapreduce/trunk/src/examples/org/apache/hadoop/examples/QuasiMonteCarlo.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/examples/org/apache/hadoop/examples/QuasiMonteCarlo.java?rev=956697&r1=956696&r2=956697&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/examples/org/apache/hadoop/examples/QuasiMonteCarlo.java (original)
+++ hadoop/mapreduce/trunk/src/examples/org/apache/hadoop/examples/QuasiMonteCarlo.java Mon
Jun 21 21:18:57 2010
@@ -20,6 +20,7 @@ package org.apache.hadoop.examples;
 
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configured;
@@ -318,10 +319,11 @@ public class QuasiMonteCarlo extends Con
       }
 
       //compute estimated value
+      final BigDecimal numTotal
+          = BigDecimal.valueOf(numMaps).multiply(BigDecimal.valueOf(numPoints));
       return BigDecimal.valueOf(4).setScale(20)
           .multiply(BigDecimal.valueOf(numInside.get()))
-          .divide(BigDecimal.valueOf(numMaps))
-          .divide(BigDecimal.valueOf(numPoints));
+          .divide(numTotal, RoundingMode.HALF_UP);
     } finally {
       fs.delete(TMP_DIR, true);
     }



Mime
View raw message