Package org.apfloat.internal
Class IntCRTMath
- java.lang.Object
-
- org.apfloat.internal.IntBaseMath
-
- org.apfloat.internal.IntCRTMath
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
IntCarryCRTStepStrategy
public class IntCRTMath extends IntBaseMath
Basic arithmetic for calculating the Chinese Remainder Theorem. Works for theint
type.- Version:
- 1.6
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private int
base
private static int
BASE_MASK
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description IntCRTMath(int radix)
Creates a carry-CRT math using the specified radix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
add(int[] src, int[] srcDst)
Adds three words.int
compare(int[] src1, int[] src2)
Compares three words.int
divide(int[] srcDst)
Divides three words by the base to produce two words.void
multiply(int[] src, int factor, int[] dst)
Multiplies two words by one word to produce a result of three words.void
subtract(int[] src, int[] srcDst)
Subtracts three words.-
Methods inherited from class org.apfloat.internal.IntBaseMath
baseAdd, baseDivide, baseMultiplyAdd, baseSubtract
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
BASE_MASK
private static final int BASE_MASK
- See Also:
- Constant Field Values
-
base
private int base
-
-
Method Detail
-
multiply
public final void multiply(int[] src, int factor, int[] 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 int compare(int[] src1, int[] 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 > src2
and zero ifsrc1 == src2
.
-
add
public final int add(int[] src, int[] 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(int[] src, int[] 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 int divide(int[] 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.
-
-