diff options
author | Dan Gohman <gohman@apple.com> | 2008-02-29 01:26:11 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-02-29 01:26:11 +0000 |
commit | 93c276e1c92da03ce9805fd3f3814b5e9b8cd57c (patch) | |
tree | 617eb409446e32dac79adc69b0f270346bb14428 /lib/Support/APFloat.cpp | |
parent | d703ed6aed98c8156829399efbafb13a3cca0b69 (diff) |
Add a method to APFloat to convert directly from APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47738 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/APFloat.cpp')
-rw-r--r-- | lib/Support/APFloat.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp index cc86e795e7..3b44820884 100644 --- a/lib/Support/APFloat.cpp +++ b/lib/Support/APFloat.cpp @@ -1913,6 +1913,23 @@ APFloat::convertFromUnsignedParts(const integerPart *src, return normalize(rounding_mode, lost_fraction); } +APFloat::opStatus +APFloat::convertFromAPInt(const APInt &Val, + bool isSigned, + roundingMode rounding_mode) +{ + unsigned int partCount = Val.getNumWords(); + APInt api = Val; + + sign = false; + if (isSigned && api.isNegative()) { + sign = true; + api = -api; + } + + return convertFromUnsignedParts(api.getRawData(), partCount, rounding_mode); +} + /* Convert a two's complement integer SRC to a floating point number, rounding according to ROUNDING_MODE. ISSIGNED is true if the integer is signed, in which case it must be sign-extended. */ |