Package org.apfloat.samples
Class Pi
java.lang.Object
org.apfloat.samples.Pi
- Direct Known Subclasses:
PiParallel
Calculates pi using four different algorithms.
- Version:
- 1.14.0
- Author:
- Mikko Tommila
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classAbstract base class for the binary splitting series.protected static classClass for implementing the binary splitting algorithm.static classIndicates progress of the pi calculation using the binary splitting algorithm.protected static interfaceTerms for the binary splitting series.static classCalculates pi using the Borweins' quartic algorithm.protected static classChudnovskys' algorithm terms for the binary splitting series.static classBasic class for calculating pi using the Chudnovskys' binary splitting algorithm.static classCalculates pi using the Gauss-Legendre algorithm.protected static classRamanujan's algorithm terms for the binary splitting series.static classBasic class for calculating pi using the Ramanujan binary splitting algorithm. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static PrintWriterOutput stream for status messages printout.protected static PrintWriterOutput stream for the result printout. -
Method Summary
Modifier and TypeMethodDescriptionstatic PrintWritergetErr()Get the output stream for status messages printout.protected static intParse an integer from an argument.protected static longParse a long from an argument.static PrintWritergetOut()Get the output stream for the result printout.protected static longgetPrecision(String arg) Parse the precision from an argument.protected static intParse the radix from an argument.static voidCommand-line entry point.static voidExecute an operation and display some additional information.static voidsetErr(PrintWriter err) Set the output stream for status messages printout.static voidsetOut(PrintWriter out) Set the output stream for the result printout.
-
Field Details
-
out
Output stream for the result printout. -
err
Output stream for status messages printout.
-
-
Method Details
-
getLong
-
getInt
-
getPrecision
Parse the precision from an argument.- Parameters:
arg- The string to be parsed.- Returns:
- Valid precision.
-
getRadix
Parse the radix from an argument.- Parameters:
arg- The string to be parsed.- Returns:
- Valid radix.
-
run
public static void run(long precision, int radix, Operation<Apfloat> operation) throws IOException, ApfloatRuntimeException Execute an operation and display some additional information. The return value of the operation is written toout.- Parameters:
precision- The precision to be used.radix- The radix to be used.operation- The operation to execute.- Throws:
IOException- In case writing the output fails.ApfloatRuntimeException
-
setOut
Set the output stream for the result printout.- Parameters:
out- The output stream.
-
getOut
Get the output stream for the result printout.- Returns:
- The output stream.
-
setErr
Set the output stream for status messages printout.- Parameters:
err- The output stream.
-
getErr
Get the output stream for status messages printout.- Returns:
- The output stream.
-
main
Command-line entry point.- Parameters:
args- Command-line parameters.- Throws:
IOException- In case writing the output fails.ApfloatRuntimeException
-