Imp
[using it]
Interface Manipulation Package v4.0 (2008-06-25) a-projector ©copyright Author


imp.core
Class Numeric

java.lang.Object
  extended by imp.core.Value
      extended by imp.core.Numeric
All Implemented Interfaces:
Cloneable, Comparable<Value>

public class Numeric
extends Value

Implements an arbitrary-precision signed numerical value.

Integer and floating-point numbers are defined by the following common standard syntax:
$integer = ([-])?([0-9])?+
$hexadecimal-integer = [#]([0-9a-fA-F])?+
$float = $integer([.]$integer)?([eE]$integer)?


Field Summary
 
Fields inherited from class imp.core.Value
NULL
 
Method Summary
 Numeric add(Numeric value)
          Returns a value equal to (this + value).
static Numeric atan2(Numeric x, Numeric y)
          Converts approximately rectangular coordinates (x, y) to the polar phase theta.
 byte byteValue()
          Returns the value of the specified number as a byte.
 int compareTo(Value value)
          Compares this with the specified value.
 BigDecimal decimalValue()
          Returns the value of the specified number as a big decimal.
 Numeric divide(Numeric value)
          Returns a value equal to (this / value) using integer division.
 double doubleValue()
          Returns the value of the specified number as a double.
static double doubleValue(Value value, double optionalDefaultValue)
          Returns the value as a double.
 Numeric exp()
          Returns a value approximately equals to exp(this), the Euler's number raised to the power of this.
 float floatValue()
          Returns the value of the specified number as a float.
 BigDecimal getValue()
          Gets this numeric value.
 BigInteger integerValue()
          Returns the value of the specified number as a big integer.
 int intValue()
          Returns the value of the specified number as an int.
static int intValue(Value value, int optionalDefaultValue)
          Returns the value as an integer.
 Numeric inverse()
          Returns a value equal to (1.0/this).
 Numeric log()
          Returns a value approximately equals to log(this), the natural logarithm (base e).
 long longValue()
          Returns the value of the specified number as a long.
static long longValue(Value value, long optionalDefaultValue)
          Returns the value as a long.
 Numeric mul(Numeric value)
          Returns a value equal to (this * value).
 Numeric negate()
          Returns a value equal to (-this).
static Numeric numberValue(Value value, Numeric optionalDefaultValue)
          Return the value as a number.
 Numeric pow(Numeric value)
          Returns a value approximately equals to this^value.
 Numeric round()
          Returns an integer value approximately equals to this.
 Numeric setValue(String value)
          Sets this value (thus erase previous value) from the given string and return this.
 short shortValue()
          Returns the value of the specified number as a short.
 
Methods inherited from class imp.core.Value
add, create, elements, fields, get, getType, getWrapping, isName, length, load, main, save, set, toString, wrappedObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

add

public final Numeric add(Numeric value)
Returns a value equal to (this + value).


atan2

public static final Numeric atan2(Numeric x,
                                  Numeric y)
Converts approximately rectangular coordinates (x, y) to the polar phase theta.


byteValue

public final byte byteValue()
Returns the value of the specified number as a byte.


compareTo

public final int compareTo(Value value)
Compares this with the specified value.

Specified by:
compareTo in interface Comparable<Value>
Parameters:
value - value to which this is to be compared, default is a number equal to 0.
Returns:
-1, 0 or 1 as this is numerically less than, equal to, or greater than val.

decimalValue

public final BigDecimal decimalValue()
Returns the value of the specified number as a big decimal.


divide

public final Numeric divide(Numeric value)
Returns a value equal to (this / value) using integer division.


doubleValue

public final double doubleValue()
Returns the value of the specified number as a double.


doubleValue

public static final double doubleValue(Value value,
                                       double optionalDefaultValue)
Returns the value as a double.


exp

public final Numeric exp()
Returns a value approximately equals to exp(this), the Euler's number raised to the power of this.


floatValue

public final float floatValue()
Returns the value of the specified number as a float.


getValue

public final BigDecimal getValue()
Gets this numeric value.


integerValue

public final BigInteger integerValue()
Returns the value of the specified number as a big integer.


intValue

public final int intValue()
Returns the value of the specified number as an int.


intValue

public static final int intValue(Value value,
                                 int optionalDefaultValue)
Returns the value as an integer.


inverse

public final Numeric inverse()
                      throws ArithmeticException
Returns a value equal to (1.0/this).
Rounding is performed towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor (this is the rounding mode that minimizes cumulative error when applied repeatedly over a sequence of calculations).

Throws:
ArithmeticException - if this is zero.

log

public final Numeric log()
Returns a value approximately equals to log(this), the natural logarithm (base e).


longValue

public final long longValue()
Returns the value of the specified number as a long.


longValue

public static final long longValue(Value value,
                                   long optionalDefaultValue)
Returns the value as a long.


mul

public final Numeric mul(Numeric value)
Returns a value equal to (this * value).


negate

public final Numeric negate()
Returns a value equal to (-this).


numberValue

public static final Numeric numberValue(Value value,
                                        Numeric optionalDefaultValue)
Return the value as a number.


pow

public final Numeric pow(Numeric value)
Returns a value approximately equals to this^value.


round

public final Numeric round()
Returns an integer value approximately equals to this.


setValue

public final Numeric setValue(String value)
Sets this value (thus erase previous value) from the given string and return this.

Parameters:
value - A string defining the present value. The java null value is not allowed.
As Number|double|long:
A number viewed as a string.
By contract, implementation of this interface have similar methods with other pertinent type input value.
Integer and floating-point numbers are defined using the standard syntax (e.g. 3.1416, -12e+6). Hexadecimal values are prefixed with # (e.g. #ff00ff).
Returns:
A reference to this object, allowing to define a value with the following construct: new Imp().setValue(value);.
Throws:
IllegalStateException - if the value can not be set.
IllegalArgumentException - if the value is not valid.

shortValue

public final short shortValue()
Returns the value of the specified number as a short.