package org.matheclipse.core.interfaces;
/**
* interface for "ractional" numbers (i.e. IInteger or IFraction)
*
*/
public interface ISignedNumber extends INumber {
/**
* Test if this number is negative.
*
* @return true, if this < 0
*/
public boolean isNegative();
/**
* Test if this number is positive.
*
* @return true, if this > 0
*/
public boolean isPositive();
/** {@inheritDoc} */
public boolean isZero();
public boolean isLessThan(ISignedNumber that);
public boolean isGreaterThan(ISignedNumber that);
/**
* Returns (-1) * this
*
* @return
*/
public ISignedNumber negate();
/**
* Divide this signed number by that signed number.
*
* @param that
* a signed number
* @return
*/
public ISignedNumber divideBy(ISignedNumber that);
/**
* Subtract that signed number from this signed number
*
* @param that
* a signed number
* @return
*/
public ISignedNumber subtractFrom(ISignedNumber that);
/**
* Returns the signum function of this number (i.e., -1, 0 or 1 as the value of this number is negative, zero or positive).
*
* @return -1 if this is a negative number;
* 0 if this is a zero;
* -1 if this is a negative number;
*/
public int sign();
/**
* Converts this number to int; unlike {@link #intValue} this method raises {@link ArithmeticException} if this
* number cannot be represented by an int type.
*
* @return the numeric value represented by this integer after conversion to type int.
* @throws ArithmeticException
* if conversion to int is not possible.
*/
public int toInt() throws ArithmeticException;
/**
* Converts this number to long; unlike {@link #longValue} this method raises {@link ArithmeticException} if this
* number cannot be represented by an long type.
*
* @return the numeric value represented by this integer after conversion to type long.
* @throws ArithmeticException
* if conversion to int is not possible.
*/
public long toLong() throws ArithmeticException;
/**
* Returns the smallest (closest to negative infinity) IInteger value that is not less than this and
* is equal to a mathematical integer. This method raises {@link ArithmeticException} if a numeric value cannot be represented
* by an long type.
*
* @return the smallest (closest to negative infinity) IInteger value that is not less than this and
* is equal to a mathematical integer.
*/
public IInteger ceil() throws ArithmeticException;
/**
* Returns the largest (closest to positive infinity) IInteger value that is not greater than this and
* is equal to a mathematical integer.
* This method raises {@link ArithmeticException} if a numeric value cannot be represented by an long type.
*
* @return the largest (closest to positive infinity) IInteger value that is not greater than this and
* is equal to a mathematical integer.
*/
public IInteger floor() throws ArithmeticException;
/**
* Returns the closest IInteger to the argument. The result is rounded to an integer by adding 1/2 and taking the
* floor of the result.
* This method raises {@link ArithmeticException} if a numeric value cannot be represented by an long type.
*
* @return the closest integer to the argument.
*/
public IInteger round();
public ISignedNumber inverse();
public ISignedNumber opposite();
public double doubleValue();
}
Ads help maintain this website.