Class ccj.Numeric
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ccj.Numeric

java.lang.Object
   |
   +----ccj.Numeric

public class Numeric
extends Object

Constructor Index

 o Numeric()

Method Index

 o compareDoubles(double, double)
Compares two floating point numbers to see if they are approximately the same
 o parseDouble(String)
Converts a string to a floating point number.
 o randomDouble(double, double)
Generates a random floating point number in a range.
 o randomInt(int, int)
Generates a random integer in a range.
 o round(double)
Rounds a floating point number to the nearest integer

Constructors

 o Numeric
  public Numeric()

Methods

 o parseDouble
  public static double parseDouble(String s)
Converts a string to a floating point number. For example, Numeric.parseDouble("0.5") returns 0.5
Parameters:
s - the string to parse
Returns:
the floating point value represented by the string.
 o compareDoubles
  public static int compareDoubles(double x,
                                   double y)
Compares two floating point numbers to see if they are approximately the same
Parameters:
x - a floating point number
y - another floating point number
Returns:
0 if x and y are approximately identical, -1 if x < y and 1 if x > y
 o round
  public static int round(double x)
Rounds a floating point number to the nearest integer
Parameters:
x - a floating point number
Returns:
the nearest integer
 o randomInt
  public static int randomInt(int a,
                              int b)
Generates a random integer in a range. For example, Numeric.randomInt(1, 6) generates a random roll of a die
Parameters:
a - the low bound of the range
b - the high bound of the range
Returns:
a random integer r, a <= r && r <= b
 o randomDouble
  public static double randomDouble(double a,
                                    double b)
Generates a random floating point number in a range.
Parameters:
a - the low bound of the range (inclusive)
b - the high bound of the range (exclusive)
Returns:
a random floating point number r, a <= r && r < b

All Packages  Class Hierarchy  This Package  Previous  Next  Index