org.apfloat
Class AprationalMath

java.lang.Object
  |
  +--org.apfloat.AprationalMath

public class AprationalMath
extends java.lang.Object

Various mathematical functions for arbitrary precision rational numbers.


Method Summary
static Aprational abs(Aprational x)
          Absolute value.
static Aprational negate(Aprational x)
          Returns an aprational whose value is -x.
static Aprational pow(Aprational x, long n)
          Integer power.
static Aprational scale(Aprational x, long scale)
          Multiply by a power of the radix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

pow

public static Aprational pow(Aprational x,
                             long n)
                      throws java.lang.ArithmeticException,
                             ApfloatRuntimeException
Integer power.

Parameters:
x - Base of the power operator.
n - Exponent of the power operator.
Returns:
x to the n:th power, that is xn.
Throws:
java.lang.ArithmeticException - If both x and n are zero.
ApfloatRuntimeException

negate

public static Aprational negate(Aprational x)
                         throws ApfloatRuntimeException
Returns an aprational whose value is -x.

Parameters:
x - The argument.
Returns:
-x.
ApfloatRuntimeException

abs

public static Aprational abs(Aprational x)
                      throws ApfloatRuntimeException
Absolute value.

Parameters:
x - The argument.
Returns:
Absolute value of x.
ApfloatRuntimeException

scale

public static Aprational scale(Aprational x,
                               long scale)
                        throws ApfloatRuntimeException
Multiply by a power of the radix. Note that this method is prone to intermediate overflow errors. Also scaling by a very large negative number won't result in an underflow and a zero result, but an overflow of the denominator and an exception thrown.

Parameters:
x - The argument.
scale - The scaling factor.
Returns:
x*x.radix()scale.
ApfloatRuntimeException