Scribble Problem Set Javadocs

cs101.util
Class MoreMath

java.lang.Object
  extended bycs101.util.MoreMath

public class MoreMath
extends java.lang.Object

cs101.util.MoreMath is an extension of the java.lang.Math library.
Copyright 1996 Massachusetts Institute of Technology

Author:
Todd C. Parnell, tparnell@ai.mit.edu, Lynn Andrea Stein, las@ai.mit.edu

Method Summary
static int randomInt(int range)
          Generate a random int between 0 and range.
static int sign(int x)
          Returns 1 if the input is positive, -1 if it is negative, and 0 otherwise.
static int square(int x)
          Returns the square of the input.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

randomInt

public static int randomInt(int range)
Generate a random int between 0 and range. Note that if range is negative, this returns a negative number.

Parameters:
range - desired maximum int.

square

public static int square(int x)
Returns the square of the input. No checks are made for MaxInt overflow.

Parameters:
x - the number to square

sign

public static int sign(int x)
Returns 1 if the input is positive, -1 if it is negative, and 0 otherwise.

Parameters:
x - the number to get the sign of

Scribble Problem Set Javadocs