Package org.apfloat.internal
Class LongCRTMath
- java.lang.Object
-
- org.apfloat.internal.LongBaseMath
-
- org.apfloat.internal.LongCRTMath
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
LongCarryCRTStepStrategy
public class LongCRTMath extends LongBaseMath
Basic arithmetic for calculating the Chinese Remainder Theorem. Works for thelongtype.- Version:
- 1.6
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private longbaseprivate static longBASE_MASKprivate static doubleINVERSE_MAX_POWER_OF_TWO_BASEprivate doubleinverseBaseprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description LongCRTMath(int radix)Creates a carry-CRT math using the specified radix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longadd(long[] src, long[] srcDst)Adds three words.longcompare(long[] src1, long[] src2)Compares three words.longdivide(long[] srcDst)Divides three words by the base to produce two words.voidmultiply(long[] src, long factor, long[] dst)Multiplies two words by one word to produce a result of three words.voidsubtract(long[] src, long[] srcDst)Subtracts three words.-
Methods inherited from class org.apfloat.internal.LongBaseMath
baseAdd, baseDivide, baseMultiplyAdd, baseSubtract
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
BASE_MASK
private static final long BASE_MASK
- See Also:
- Constant Field Values
-
INVERSE_MAX_POWER_OF_TWO_BASE
private static final double INVERSE_MAX_POWER_OF_TWO_BASE
- See Also:
- Constant Field Values
-
base
private long base
-
inverseBase
private double inverseBase
-
-
Method Detail
-
multiply
public final void multiply(long[] src, long factor, long[] dst)Multiplies two words by one word to produce a result of three words. Most significant word is stored first.- Parameters:
src- Source array, first multiplicand.factor- Second multiplicand.dst- Destination array.
-
compare
public final long compare(long[] src1, long[] src2)Compares three words. Most significant word is stored first.- Parameters:
src1- First operand.src2- Second operand.- Returns:
- Less than zero if
src1 < src2, greater than zero ifsrc1 > src2and zero ifsrc1 == src2.
-
add
public final long add(long[] src, long[] srcDst)Adds three words. Most significant word is stored first.- Parameters:
src- First operand.srcDst- Second operand, and destination of the operation.- Returns:
- Overflow carry bit.
-
subtract
public final void subtract(long[] src, long[] srcDst)Subtracts three words. Most significant word is stored first.- Parameters:
src- First operand.srcDst- Second operand, and destination of the operation.
-
divide
public final long divide(long[] srcDst)
Divides three words by the base to produce two words. Most significant word is stored first.- Parameters:
srcDst- Source and destination of the operation.- Returns:
- Remainder of the division.
-
-