Package org.apfloat.internal
Class DoubleAdditionStrategy
- java.lang.Object
-
- org.apfloat.internal.DoubleBaseMath
-
- org.apfloat.internal.DoubleAdditionStrategy
-
- All Implemented Interfaces:
java.io.Serializable,AdditionStrategy<java.lang.Double>
public class DoubleAdditionStrategy extends DoubleBaseMath implements AdditionStrategy<java.lang.Double>
Basic addition strategy for thedoubleelement type.- Since:
- 1.7.0
- Version:
- 1.7.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description DoubleAdditionStrategy(int radix)Creates an addition strategy using the specified radix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Doubleadd(DataStorage.Iterator src1, DataStorage.Iterator src2, java.lang.Double carry, DataStorage.Iterator dst, long size)Addition in some base.java.lang.Doubledivide(DataStorage.Iterator src1, java.lang.Double src2, java.lang.Double carry, DataStorage.Iterator dst, long size)Division in some base.java.lang.DoublemultiplyAdd(DataStorage.Iterator src1, DataStorage.Iterator src2, java.lang.Double src3, java.lang.Double carry, DataStorage.Iterator dst, long size)Multiplication and addition in some base.java.lang.Doublesubtract(DataStorage.Iterator src1, DataStorage.Iterator src2, java.lang.Double carry, DataStorage.Iterator dst, long size)Subtraction in some base.java.lang.Doublezero()Returns the zero element.-
Methods inherited from class org.apfloat.internal.DoubleBaseMath
baseAdd, baseDivide, baseMultiplyAdd, baseSubtract
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
add
public java.lang.Double add(DataStorage.Iterator src1, DataStorage.Iterator src2, java.lang.Double carry, DataStorage.Iterator dst, long size) throws ApfloatRuntimeException
Description copied from interface:AdditionStrategyAddition in some base. Adds the data words ofsrc1andsrc2and stores the result todst.src2may benull, in which case it is ignored (only the carry is propagated).Essentially calculates
dst[i] = src1[i] + src2[i].- Specified by:
addin interfaceAdditionStrategy<java.lang.Double>- Parameters:
src1- First source data sequence. Can benull, in which case it's ignored.src2- Second source data sequence. Can benull, in which case it's ignored.carry- Input carry bit. This is added to the first (rightmost) word in the accessed sequence.dst- Destination data sequence.size- Number of elements to process.- Returns:
- Overflow carry bit. Propagated carry bit from the addition of the last (leftmost) word in the accessed sequence.
- Throws:
ApfloatRuntimeException
-
subtract
public java.lang.Double subtract(DataStorage.Iterator src1, DataStorage.Iterator src2, java.lang.Double carry, DataStorage.Iterator dst, long size) throws ApfloatRuntimeException
Description copied from interface:AdditionStrategySubtraction in some base. Subtracts the data words ofsrc1andsrc2and stores the result todst.src1andsrc2may benull, in which case they are ignored (the values are assumed to be zero and only the carry is propagated).Essentially calculates
dst[i] = src1[i] - src2[i].- Specified by:
subtractin interfaceAdditionStrategy<java.lang.Double>- Parameters:
src1- First source data sequence. Can benull, in which case the input values are assumed to be zero.src2- Second source data sequence. Can benull, in which case it's ignored, or can be the same asdst.carry- Input carry bit. This is subtracted from the first (rightmost) word in the accessed sequence.dst- Destination data sequence.size- Number of elements to process.- Returns:
- Overflow carry bit. Propagated carry bit from the subtraction of the last (leftmost) word in the accessed sequence. The value is
1if the carry is set, and0otherwise. - Throws:
ApfloatRuntimeException
-
multiplyAdd
public java.lang.Double multiplyAdd(DataStorage.Iterator src1, DataStorage.Iterator src2, java.lang.Double src3, java.lang.Double carry, DataStorage.Iterator dst, long size) throws ApfloatRuntimeException
Description copied from interface:AdditionStrategyMultiplication and addition in some base. Multiplies the data words ofsrc1bysrc3and adds the result to the words insrc2, and stores the result todst.src2may benull, in which case it is ignored (the values are assumed to be zero).Assumes that the result from the addition doesn't overflow the upper result word (to larger than the base). This is the case e.g. when using this method to perform an arbitrary precision multiplication.
Essentially calculates
dst[i] = src1[i] * src3 + src2[i].- Specified by:
multiplyAddin interfaceAdditionStrategy<java.lang.Double>- Parameters:
src1- First source data sequence.src2- Second source data sequence. Can benull, in which case it's ignored, or can be the same asdst.src3- Multiplicand. All elements ofsrc1are multiplied by this value.carry- Input carry word. This is added to the first (rightmost) word in the accessed sequence.dst- Destination data sequence.size- Number of elements to process.- Returns:
- Overflow carry word. Propagated carry word from the multiplication and addition of the last (leftmost) word in the accessed sequence.
- Throws:
ApfloatRuntimeException
-
divide
public java.lang.Double divide(DataStorage.Iterator src1, java.lang.Double src2, java.lang.Double carry, DataStorage.Iterator dst, long size) throws ApfloatRuntimeException
Description copied from interface:AdditionStrategyDivision in some base. Divides the data words ofsrc1bysrc2and stores the result todst.src1may benull, in which case it is ignored (the values are assumed to be zero and only the carry division is propagated).Essentially calculates
dst[i] = src1[i] / src2.- Specified by:
dividein interfaceAdditionStrategy<java.lang.Double>- Parameters:
src1- First source data sequence. Can benull, in which case the input values are assumed to be zero.src2- Divisor. All elements ofsrc1are divided by this value.carry- Input carry word. Used as the upper word for the division of the first input element. This should be the remainder word returned from the previous block processed.dst- Destination data sequence.size- Number of elements to process.- Returns:
- Remainder word of the propagated division of the last (rightmost) word in the accessed sequence.
- Throws:
ApfloatRuntimeException
-
zero
public java.lang.Double zero()
Description copied from interface:AdditionStrategyReturns the zero element.- Specified by:
zeroin interfaceAdditionStrategy<java.lang.Double>- Returns:
- Zero of the correct element type.
-
-