From 7fa28c4ebfe7f5496a71b8d156ed5887eb43295a Mon Sep 17 00:00:00 2001 From: Arthur Drobot Date: Wed, 2 Aug 2017 14:13:30 -0700 Subject: [PATCH] Fix getPi function. --- src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java b/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java index 3db5c1a..a20f5c4 100755 --- a/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java +++ b/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java @@ -405,7 +405,7 @@ public class StandardPlugin extends Plugin { NumberInterface L = new NaiveNumber(13591409).promoteTo(numClass); NumberInterface X = M; NumberInterface sum = L; - int termsNeeded = C.getMaxPrecision()/13; + int termsNeeded = C.getMaxPrecision()/13 + 1; NumberInterface lSummand = new NaiveNumber(545140134).promoteTo(L.getClass()); NumberInterface xMultiplier = new NaiveNumber(262537412).promoteTo(X.getClass()) @@ -420,9 +420,9 @@ public class StandardPlugin extends Plugin { .divide(new NaiveNumber(Math.pow(i+1,3)).promoteTo(M.getClass())); L = L.add(lSummand); X = X.multiply(xMultiplier); - sum = sum.add(M.add(L).divide(X)); + sum = sum.add(M.multiply(L).divide(X)); } - piValues.put(numClass, NaiveNumber.ONE.promoteTo(numClass).divide(sum).multiply(C)); + piValues.put(numClass, C.divide(sum)); } return piValues.get(numClass); }