|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--MyNumbers
Generic utility functions for MyNumbers.
| Method Summary | |
static MyNumber |
abs(MyNumber n)
Returns a new MyNumber object that initially holds
the absolute value of n. |
static boolean |
divides(MyNumber m0,
MyNumber n0)
Returns true if m divides n
evenly. |
static boolean |
isNegative(MyNumber n)
Returns true if n is negative. |
static boolean |
isZero(MyNumber n)
Returns true if n is zero. |
| Methods inherited from class java.lang.Object |
|
| Method Detail |
public static boolean isZero(MyNumber n)
true if n is zero.n - the number to testtrue if n is zero;
false otherwisepublic static boolean isNegative(MyNumber n)
true if n is negative.n - the number to testtrue if n is less than zero;
false otherwisepublic static MyNumber abs(MyNumber n)
MyNumber object that initially holds
the absolute value of n.
[The returned object is guaranteed to be an instance of
n's class.]
n - the number whose is magnitude is to be takenMyNumber object whose initial value
is the magnitude of n
public static boolean divides(MyNumber m0,
MyNumber n0)
true if m divides n
evenly. When n and m are both positive,
this is equivalent to saying that true is returned iff
n = m + m + m + ... + m + m + mwhere
m may be repeated zero or more times on the
right-hand side.
[For consistency with MyInteger, the divides
method's behavior is undefined when m is zero.]
m - the number to divide byn - the number to divide intotrue if m divides n
evenly; false otherwise
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||