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
-
EDU.emporia.mathtools.MathUtility()
-
-
displayFormat(double, int, int)
- Returns a String description of a number that is
suitable for fitting into a fixed width field.
-
displayFormat(double, int)
- overloaded version of displayFormat that makes
leadingZeros equal to 4.
-
displayFormat(double)
- Overloaded version of displayFormat that makes
the fieldWidth 8 and the leadingZeros 4
-
log10(double)
- Returns the logarithm to the base 10
-
parseDouble(String)
- Attempts to convert a String expression into a double
-
removeZeros(String)
- Removes extraneous trailing zeros from a decimal expression
-
roundDecimal(double, int)
- Rounds the number off to a given number of
significant digits.
MathUtility
public MathUtility()
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
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.
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
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
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
removeZeros
public static java.lang.String removeZeros(String s)
- Removes extraneous trailing zeros from a decimal expression
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