diff options
author | Dale Johannesen <dalej@apple.com> | 2007-08-31 23:35:31 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2007-08-31 23:35:31 +0000 |
commit | e15c2db9935eee66a8008f1bd09882aff2ed3aae (patch) | |
tree | e02d9bda42fd4d6faa6951b92e68deb11706be54 /lib/Support/APFloat.cpp | |
parent | c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeaca (diff) |
Oops, should be part of 41664; won't work very well without this piece.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41665 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/APFloat.cpp')
-rw-r--r-- | lib/Support/APFloat.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp index b61e6220a1..a0185ad51e 100644 --- a/lib/Support/APFloat.cpp +++ b/lib/Support/APFloat.cpp @@ -1065,6 +1065,20 @@ APFloat::changeSign() sign = !sign; } +void +APFloat::clearSign() +{ + /* So is this one. */ + sign = 0; +} + +void +APFloat::copySign(const APFloat &rhs) +{ + /* And this one. */ + sign = rhs.sign; +} + /* Normalized addition or subtraction. */ APFloat::opStatus APFloat::addOrSubtract(const APFloat &rhs, roundingMode rounding_mode, @@ -1148,6 +1162,30 @@ APFloat::divide(const APFloat &rhs, roundingMode rounding_mode) return fs; } +/* Normalized remainder. */ +APFloat::opStatus +APFloat::mod(const APFloat &rhs, roundingMode rounding_mode) +{ + opStatus fs; + APFloat V = *this; + fs = V.divide(rhs, rmNearestTiesToEven); + if (fs == opDivByZero) + return fs; + + integerPart x; + fs = V.convertToInteger(&x, integerPartWidth, true, rmNearestTiesToEven); + if (fs==opInvalidOp) + return fs; + + fs = V.convertFromInteger(&x, integerPartWidth, true, rmNearestTiesToEven); + assert(fs==opOK); // should always work + fs = V.multiply(rhs, rounding_mode); + assert(fs==opOK); // should not overflow or underflow + fs = subtract(V, rounding_mode); + assert(fs==opOK); + return fs; +} + /* Normalized fused-multiply-add. */ APFloat::opStatus APFloat::fusedMultiplyAdd(const APFloat &multiplicand, |