From 94a48f06e56dfd5f020ac9a25a4fd051f5c0cac2 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Sat, 3 Mar 2007 08:34:02 +0000 Subject: [PATCH] Regularize the interface for conversion functions to/from float/double. llvm-svn: 34881 --- llvm/include/llvm/ADT/APInt.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index 55633ea15699..d7a604c41655 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/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. -- GitLab