net.jinx.slowmath
Class MathUtil

java.lang.Object
  extended by net.jinx.slowmath.MathUtil

public class MathUtil
extends java.lang.Object

Programs using the math library should construct their initial values via this class. It allows parsing data in a type-neutral way. This way, you can change a single line of code in your program (or use a command-line switch), and it changes the precision of the whole system.

API Stability: Beta.


Method Summary
static Real e()
           
static void main(java.lang.String[] args)
          Performs a test of this library.
static Real negOne()
           
static Real one()
           
static Real oneHalf()
           
static Real parseReal(java.lang.String s)
          Parses a value from the String.
static Vector parseVector(java.lang.String s)
          Parses a Vector from the String.
static Real pi()
           
static void setType(java.lang.String type)
          Sets what type this class should use to construct new Real instances.
static Real two()
           
static Real wrapDouble(double v)
          Constructs a type-neutral Real for the given double.
static Real wrapLong(long v)
          Wraps a long in a Real in a type-neutral manner.
static Real zero()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

main

public static void main(java.lang.String[] args)
Performs a test of this library.


setType

public static void setType(java.lang.String type)
Sets what type this class should use to construct new Real instances. This will affect the results of the parseReal(String) method.

This will only affect the current thread and is inherited by any Threads it creates.

Parameters:
type - right now, this can be either "float" or "double".

wrapDouble

public static Real wrapDouble(double v)
Constructs a type-neutral Real for the given double.

Parameters:
v - the double value.

wrapLong

public static Real wrapLong(long v)
Wraps a long in a Real in a type-neutral manner.

Parameters:
v - the long value.
Returns:
the Real wrapping v.

parseReal

public static Real parseReal(java.lang.String s)
Parses a value from the String. This will generate Real instances in a type-neutral manner.

Parameters:
s - the String to parse.

parseVector

public static Vector parseVector(java.lang.String s)
Parses a Vector from the String. This will generate Real instances in a type-neutral manner.

Parameters:
s - the String to parse.
Throws:
java.lang.IllegalArgumentException - if s has less than or more than three elements encoded in it.

zero

public static Real zero()

one

public static Real one()

oneHalf

public static Real oneHalf()

negOne

public static Real negOne()

two

public static Real two()

e

public static Real e()

pi

public static Real pi()