Class EDU.emporia.mathtools.MathUtility
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class EDU.emporia.mathtools.MathUtility

Object
   |
   +----EDU.emporia.mathtools.MathUtility

public class MathUtility
extends Object
This class contains a number of static methods that can be useful for creating mathematical applets.

Version:
1.2
Author:
Joe Yanik
Since:
7/7/00

Constructor Index

 o EDU.emporia.mathtools.MathUtility()

Method Index

 o displayFormat(double, int, int)
Returns a String description of a number that is suitable for fitting into a fixed width field.
 o displayFormat(double, int)
overloaded version of displayFormat that makes leadingZeros equal to 4.
 o displayFormat(double)
Overloaded version of displayFormat that makes the fieldWidth 8 and the leadingZeros 4
 o log10(double)
Returns the logarithm to the base 10
 o parseDouble(String)
Attempts to convert a String expression into a double
 o removeZeros(String)
Removes extraneous trailing zeros from a decimal expression
 o roundDecimal(double, int)
Rounds the number off to a given number of significant digits.

Constructors

 o MathUtility
public MathUtility()

Methods

 o displayFormat
public static java.lang.String displayFormat(double x,
                                             int fieldWidth,
                                             int leadingZeros)
Returns a String description of a number that is suitable for fitting into a fixed width field.

Parameters:
x - the number to be formatted
fieldWidth - the width of the field (not counting the decimal point) fieldWidth will always be at least 6.
leadingZeros - The maximum number of leading zeros that should be displayed to the left of the decimal point before it shifts into exponential notation.
Returns:
A String description of the number
 o displayFormat
public static java.lang.String displayFormat(double x,
                                             int fieldWidth)
overloaded version of displayFormat that makes leadingZeros equal to 4.

Parameters:
x - The number to be formatted
fieldWidth - The width of the field (not counting the decimal point)
Returns:
A String description of the number.
 o displayFormat
public static java.lang.String displayFormat(double x)
Overloaded version of displayFormat that makes the fieldWidth 8 and the leadingZeros 4

Parameters:
x - The number to be formatted
Returns:
A String description of the number
 o log10
public static double log10(double x)
Returns the logarithm to the base 10

Parameters:
x - the x-value to be used for the logarithme
Returns:
the log to the base 10 of x
 o parseDouble
public static double parseDouble(String s) throws MathSyntaxError
Attempts to convert a String expression into a double

Parameters:
s - The String to be converted
Returns:
The double precision floating point number corresponding to the expression
Throws: MathSyntaxError
This is thrown if the parser is unable to parse the expression
 o removeZeros
public static java.lang.String removeZeros(String s)
Removes extraneous trailing zeros from a decimal expression

 o roundDecimal
public static double roundDecimal(double x,
                                  int d)
Rounds the number off to a given number of significant digits.

Parameters:
x - The number to be rounded
d - The number of significant digits
Returns:
x rounded to d significant digits.

All Packages  Class Hierarchy  This Package  Previous  Next  Index