gnu.math
Class RealNum

java.lang.Object
  extended by java.lang.Number
      extended by gnu.math.Numeric
          extended by gnu.math.Quantity
              extended by gnu.math.Complex
                  extended by gnu.math.RealNum
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable
Direct Known Subclasses:
DFloNum, RatNum

public abstract class RealNum
extends Complex
implements java.lang.Comparable

See Also:
Serialized Form

Field Summary
 
Fields inherited from class gnu.math.Numeric
CEILING, FLOOR, ROUND, TRUNCATE
 
Constructor Summary
RealNum()
           
 
Method Summary
 Numeric abs()
           
abstract  Numeric add(java.lang.Object obj, int k)
          Return this + k * obj.
static RealNum add(RealNum x, RealNum y, int k)
           
 java.math.BigDecimal asBigDecimal()
           
 int compareTo(java.lang.Object o)
          Implements the Comparable interface.
abstract  Numeric div(java.lang.Object obj)
           
static RealNum divide(RealNum x, RealNum y)
           
 Complex exp()
           
 RealNum im()
          The value of the imaginary component, as a RealNum.
abstract  boolean isNegative()
           
 boolean isZero()
           
 Complex log()
           
 RealNum max(RealNum x)
           
 RealNum min(RealNum x)
           
abstract  Numeric mul(java.lang.Object obj)
           
 RealNum re()
          The value of the real component, as a RealNum.
 RealNum rneg()
           
abstract  int sign()
          Return 1 if >0; 0 if ==0; -1 if <0; -2 if NaN.
 Complex sin()
           
 Complex sqrt()
           
static RealNum times(RealNum x, RealNum y)
           
 RatNum toExact()
          Convert to an exact number.
static IntNum toExactInt(double value)
          Converts an integral double (such as a toInt result) to an IntNum.
static IntNum toExactInt(double value, int rounding_mode)
          Converts real to an exact integer, with specified rounding mode.
 IntNum toExactInt(int rounding_mode)
          Converts to an exact integer, with specified rounding mode.
static double toInt(double d, int rounding_mode)
          Converts a real to an integer, according to a specified rounding mode.
 RealNum toInt(int rounding_mode)
          Converts a real to an integer, according to a specified rounding mode.
static IntNum toScaledInt(double f, int k)
          Convert double to (rounded) integer, after multiplying by 10**k.
 IntNum toScaledInt(int k)
          Convert this to (rounded) integer, after multiplying by 10**k.
static IntNum toScaledInt(RatNum r, int k)
          Convert rational to (rounded) integer, after multiplying by 10**k.
static java.lang.String toStringDecimal(java.lang.String dstr)
           
static java.lang.String toStringScientific(double d)
           
static java.lang.String toStringScientific(float d)
           
static java.lang.String toStringScientific(java.lang.String dstr)
          Convert result of Double.toString or Float.toString to scientific notation.
static int toStringScientific(java.lang.String dstr, java.lang.StringBuffer sbuf)
           
 
Methods inherited from class gnu.math.Complex
add, addReversed, angle, compare, compare, divide, divReversed, doubleImagValue, doubleRealValue, doubleValue, equals, equals, imMinusOne, imOne, isExact, longValue, make, make, mulReversed, neg, neg, number, polar, polar, power, times, toString
 
Methods inherited from class gnu.math.Quantity
add, compare, compareReversed, dimensions, divide, imValue, make, make, make, reValue, times, unit
 
Methods inherited from class gnu.math.Numeric
add, div_inv, floatValue, geq, grt, intValue, mul_ident, power, sub, toString
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RealNum

public RealNum()
Method Detail

re

public final RealNum re()
Description copied from class: Quantity
The value of the real component, as a RealNum. The unit() is not factored in, so you actually need to multiply by unit() to get the true real component.

Overrides:
re in class Quantity

im

public final RealNum im()
Description copied from class: Quantity
The value of the imaginary component, as a RealNum. The unit() is not factored in, so you actually need to multiply by unit() to get the true imaginary component.

Overrides:
im in class Quantity

isNegative

public abstract boolean isNegative()

sign

public abstract int sign()
Return 1 if >0; 0 if ==0; -1 if <0; -2 if NaN.


max

public RealNum max(RealNum x)

min

public RealNum min(RealNum x)

add

public static RealNum add(RealNum x,
                          RealNum y,
                          int k)

times

public static RealNum times(RealNum x,
                            RealNum y)

divide

public static RealNum divide(RealNum x,
                             RealNum y)

add

public abstract Numeric add(java.lang.Object obj,
                            int k)
Description copied from class: Numeric
Return this + k * obj.

Overrides:
add in class Complex

mul

public abstract Numeric mul(java.lang.Object obj)
Overrides:
mul in class Complex

div

public abstract Numeric div(java.lang.Object obj)
Overrides:
div in class Complex

abs

public Numeric abs()
Overrides:
abs in class Complex

rneg

public final RealNum rneg()

isZero

public boolean isZero()
Overrides:
isZero in class Complex

toExact

public RatNum toExact()
Convert to an exact number. Implements the Scheme inexact->exact (for real numbers).


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.


toExactInt

public IntNum toExactInt(int rounding_mode)
Converts to an exact integer, with specified rounding mode.


toExactInt

public static IntNum toExactInt(double value,
                                int rounding_mode)
Converts real to an exact integer, with specified rounding mode.


toExactInt

public static IntNum toExactInt(double value)
Converts an integral double (such as a toInt result) to an IntNum.


exp

public Complex exp()
Overrides:
exp in class Complex

log

public Complex log()
Overrides:
log in class Complex

sin

public final Complex sin()

sqrt

public final Complex sqrt()
Overrides:
sqrt in class Complex

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.


compareTo

public int compareTo(java.lang.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.

Specified by:
compareTo in interface java.lang.Comparable

asBigDecimal

public java.math.BigDecimal asBigDecimal()

toStringScientific

public static java.lang.String toStringScientific(float d)

toStringScientific

public static java.lang.String toStringScientific(double d)

toStringScientific

public static java.lang.String toStringScientific(java.lang.String dstr)
Convert result of Double.toString or Float.toString to scientific notation. Does not validate the input.


toStringScientific

public static int toStringScientific(java.lang.String dstr,
                                     java.lang.StringBuffer sbuf)

toStringDecimal

public static java.lang.String toStringDecimal(java.lang.String dstr)