add
public abstract Numeric add(Object obj,
int k)
Return this + k * obj.
- add in interface Complex
asBigDecimal
public BigDecimal asBigDecimal()
compareTo
public int compareTo(Object o)
Implements the Comparable interface.
This ordering isn't fully consistent with equals, since say
it returns 0 when comparing 1.5 and 3/2, though they are not equals.
isNegative
public abstract boolean isNegative()
sign
public abstract int sign()
Return 1 if >0; 0 if ==0; -1 if <0; -2 if NaN.
toExact
public RatNum toExact()
Convert to an exact number.
Implements the Scheme inexact->exact (for real numbers).
toExactInt
public static IntNum toExactInt(double value)
Converts an integral double (such as a toInt result) to an IntNum.
toExactInt
public static IntNum toExactInt(double value,
int rounding_mode)
Converts real to an exact integer, with specified rounding mode.
toExactInt
public IntNum toExactInt(int rounding_mode)
Converts to an exact integer, with specified rounding mode.
toInt
public static double toInt(double d,
int rounding_mode)
Converts a real to an integer, according to a specified rounding mode.
Note an inexact argument gives an inexact result, following Scheme.
See also RatNum.toExactInt.
toInt
public RealNum toInt(int rounding_mode)
Converts a real to an integer, according to a specified rounding mode.
Note an inexact argument gives an inexact result, following Scheme.
See also toExactInt.
toScaledInt
public static IntNum toScaledInt(double f,
int k)
Convert double to (rounded) integer, after multiplying by 10**k.
toScaledInt
public static IntNum toScaledInt(RatNum r,
int k)
Convert rational to (rounded) integer, after multiplying by 10**k.
toScaledInt
public IntNum toScaledInt(int k)
Convert this to (rounded) integer, after multiplying by 10**k.
toStringDecimal
public static String toStringDecimal(String dstr)
toStringScientific
public static String toStringScientific(String dstr)
Convert result of Double.toString or Float.toString to
scientific notation.
Does not validate the input.
toStringScientific
public static int toStringScientific(String dstr,
StringBuffer sbuf)
toStringScientific
public static String toStringScientific(double d)
toStringScientific
public static String toStringScientific(float d)