|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apfloat.samples.Pi
Calculates pi using three different algorithms.
Nested Class Summary | |
static class |
Pi.BorweinPiCalculator
Calculates pi using the Borweins' quartic algorithm. |
static class |
Pi.ChudnovskyPiCalculator
Basic class for calculating pi using the Chudnovskys' binary splitting algorithm. |
static class |
Pi.ChudnovskyProgressIndicator
Indicates progress of the pi calculation using the Chudnovskys' binary splitting algorithm. |
static class |
Pi.GaussLegendrePiCalculator
Calculates pi using the Gauss-Legendre algorithm. |
Field Summary | |
protected static java.io.PrintWriter |
err
Output stream for status messages printout. |
protected static java.io.PrintWriter |
out
Output stream for the result printout. |
Method Summary | |
protected static void |
checkAlive()
Check whether the program should stop executing. |
static java.io.PrintWriter |
getErr()
Get the output stream for status messages printout. |
protected static int |
getInt(java.lang.String arg,
java.lang.String name,
int minValue,
int maxValue)
Parse an integer from an argument. |
protected static long |
getLong(java.lang.String arg,
java.lang.String name,
long minValue,
long maxValue)
Parse a long from an argument. |
static java.io.PrintWriter |
getOut()
Get the output stream for the result printout. |
protected static long |
getPrecision(java.lang.String arg)
Parse the precision from an argument. |
protected static int |
getRadix(java.lang.String arg)
Parse the radix from an argument. |
static void |
main(java.lang.String[] args)
Command-line entry point. |
static void |
run(long precision,
int radix,
Operation operation)
Execute an operation and display some additional information. |
static void |
setAlive(boolean isAlive)
Set whether the program should stop executing. |
static void |
setErr(java.io.PrintWriter err)
Set the output stream for status messages printout. |
static void |
setOut(java.io.PrintWriter out)
Set the output stream for the result printout. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static java.io.PrintWriter out
protected static java.io.PrintWriter err
Method Detail |
protected static long getLong(java.lang.String arg, java.lang.String name, long minValue, long maxValue)
arg
- The string to be parsed.name
- Description of the argument.minValue
- Minimum allowed value.maxValue
- Maximum allowed value.
long
.protected static int getInt(java.lang.String arg, java.lang.String name, int minValue, int maxValue)
arg
- The string to be parsed.name
- Description of the argument.minValue
- Minimum allowed value.maxValue
- Maximum allowed value.
protected static long getPrecision(java.lang.String arg)
arg
- The string to be parsed.
protected static int getRadix(java.lang.String arg)
arg
- The string to be parsed.
public static void run(long precision, int radix, Operation operation) throws java.io.IOException, ApfloatRuntimeException
out
.
precision
- The precision to be used.radix
- The radix to be used.operation
- The operation to execute.
java.io.IOException
- In case writing the output fails.
ApfloatRuntimeException
public static void setOut(java.io.PrintWriter out)
out
- The output stream.public static java.io.PrintWriter getOut()
public static void setErr(java.io.PrintWriter err)
err
- The output stream.public static java.io.PrintWriter getErr()
public static void setAlive(boolean isAlive)
isAlive
- true
to keep running the program, false
to stop.public static void main(java.lang.String[] args) throws java.io.IOException, ApfloatRuntimeException
args
- Command-line parameters.
java.io.IOException
- In case writing the output fails.
ApfloatRuntimeException
protected static void checkAlive()
java.lang.ThreadDeath
- in case setAlive(boolean)
has been set to false
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |