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 class
Abstract base class for the binary splitting series.protected static class
Class for implementing the binary splitting algorithm.static class
Indicates progress of the pi calculation using the binary splitting algorithm.protected static interface
Terms for the binary splitting series.static class
Calculates pi using the Borweins' quartic algorithm.protected static class
Chudnovskys' algorithm terms for the binary splitting series.static class
Basic class for calculating pi using the Chudnovskys' binary splitting algorithm.static class
Calculates pi using the Gauss-Legendre algorithm.protected static class
Ramanujan's algorithm terms for the binary splitting series.static class
Basic class for calculating pi using the Ramanujan binary splitting algorithm. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static PrintWriter
Output stream for status messages printout.protected static PrintWriter
Output stream for the result printout. -
Method Summary
Modifier and TypeMethodDescriptionstatic PrintWriter
getErr()
Get the output stream for status messages printout.protected static int
Parse an integer from an argument.protected static long
Parse a long from an argument.static PrintWriter
getOut()
Get the output stream for the result printout.protected static long
getPrecision
(String arg) Parse the precision from an argument.protected static int
Parse the radix from an argument.static void
Command-line entry point.static void
Execute an operation and display some additional information.static void
setErr
(PrintWriter err) Set the output stream for status messages printout.static void
setOut
(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
-