net.sf.jga.fn.arithmetic
Interface IntegerArithmetic<T extends java.lang.Number>

All Superinterfaces:
Arithmetic<T>, java.io.Serializable

public interface IntegerArithmetic<T extends java.lang.Number>
extends Arithmetic<T>

Defines arithmetic operations appropriate for Integral Numbers.

An implementation of IntegerArithmetic for classes (such as BigInteger) that provide the appropriate operations can simply map these methods to the methods provided by the Number. For the reference types, the implementation will need to dereference the arguments, perform the specified operation on the resulting primitives, and box up the result in a new reference type.

Implementations of IntegerArithmetic for user-defined Number classes must be registered with the ArithmeticFactory class. See the Arithmetic class for details.

Copyright © 2003-2005 David A. Hall

Author:
David A. Hall

Method Summary
 T and(T x, T y)
          For numeric arguments x and y, returns x & y
 T modulus(T x, T y)
          For numeric arguments x and y, returns x % y
 T not(T x)
          For numeric arguments x, returns ~x
 T or(T x, T y)
          For numeric arguments x and y, returns x | y
 T shiftLeft(T x, java.lang.Integer y)
           
 T signedShiftRight(T x, java.lang.Integer y)
           
 T unsignedShiftRight(T x, java.lang.Integer y)
          Optional.
 T xor(T x, T y)
          For numeric arguments x and y, returns x ^ y
 
Methods inherited from interface net.sf.jga.fn.arithmetic.Arithmetic
divides, minus, multiplies, negate, one, plus, valueOf, zero
 

Method Detail

modulus

T modulus(T x,
          T y)
For numeric arguments x and y, returns x % y

Returns:
the modulus of the two arguments

and

T and(T x,
      T y)
For numeric arguments x and y, returns x & y

Returns:
x & y

or

T or(T x,
     T y)
For numeric arguments x and y, returns x | y

Returns:
x | y

xor

T xor(T x,
      T y)
For numeric arguments x and y, returns x ^ y

Returns:
x ^ y

not

T not(T x)
For numeric arguments x, returns ~x

Returns:
the one's complement of the argument

shiftLeft

T shiftLeft(T x,
            java.lang.Integer y)
Returns:
x << y

signedShiftRight

T signedShiftRight(T x,
                   java.lang.Integer y)
Returns:
x >> y

unsignedShiftRight

T unsignedShiftRight(T x,
                     java.lang.Integer y)
Optional.

Returns:
x >>> y


Copyright © 2002-2006 David A. Hall. All Rights Reserved.