diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-03-03 08:34:02 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-03-03 08:34:02 +0000 |
commit | 52f32d55665ef02e6ebe4518b0a1e2e2a4df0bea (patch) | |
tree | 3a5d8f694888e7e216fd122d92150f1b47149b9d | |
parent | a188bbe7ac5fd8299530c585966f3305bcc3d95b (diff) |
Regularize the interface for conversion functions to/from float/double.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34881 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/ADT/APInt.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index 55633ea156..d7a604c416 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -865,14 +865,20 @@ inline float RoundAPIntToFloat(const APInt& APIVal) { return float(RoundAPIntToDouble(APIVal)); } +/// Treast the APInt as a signed value for conversion purposes. +/// @brief Converts the given APInt to a float value. +inline float RoundSignedAPIntToFloat(const APInt& APIVal) { + return float(APIVal.signedRoundToDouble()); +} + /// RoundDoubleToAPInt - This function convert a double value to an APInt value. /// @brief Converts the given double value into a APInt. -APInt RoundDoubleToAPInt(double Double, uint32_t width = 64); +APInt RoundDoubleToAPInt(double Double, uint32_t width); /// RoundFloatToAPInt - Converts a float value into an APInt value. /// @brief Converts a float value into a APInt. -inline APInt RoundFloatToAPInt(float Float) { - return RoundDoubleToAPInt(double(Float)); +inline APInt RoundFloatToAPInt(float Float, uint32_t width) { + return RoundDoubleToAPInt(double(Float), width); } /// Arithmetic right-shift the APInt by shiftAmt. |