aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2013-06-04 03:46:25 +0000
committerMichael Gottesman <mgottesman@apple.com>2013-06-04 03:46:25 +0000
commitb30718af1ada4b68c7c44e3dcbf4891efd5e3ba1 (patch)
treebedf32c4732f762731fdff50c1eb23b371ca5e50 /include
parentf3d3952a8c104b86ec2fcb2c41078a46e0502c25 (diff)
downloadexternal_llvm-b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1.zip
external_llvm-b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1.tar.gz
external_llvm-b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1.tar.bz2
IEEE-754R 5.7.2 General Operations is* operations (except for isCanonical).
Specifically the following work was done: 1. If the operation was not implemented, I implemented it. 2. If the operation was already implemented, I just moved its location in the APFloat header into the IEEE-754R 5.7.2 section. If the name was incorrect, I put in a comment giving the true IEEE-754R name. Also unittests have been added for all of the functions which did not already have a unittest. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183179 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/ADT/APFloat.h49
1 files changed, 42 insertions, 7 deletions
diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h
index 33f997e..ffd8975 100644
--- a/include/llvm/ADT/APFloat.h
+++ b/include/llvm/ADT/APFloat.h
@@ -346,22 +346,57 @@ public:
unsigned int convertToHexString(char *dst, unsigned int hexDigits,
bool upperCase, roundingMode) const;
+ /// \name IEEE-754R 5.7.2 General operations.
+ /// @{
+
+ /// IEEE-754R isSignMinus: Returns true if and only if the current value is
+ /// negative.
+ ///
+ /// This applies to zeros and NaNs as well.
+ bool isNegative() const { return sign; }
+
+ /// IEEE-754R isNormal: Returns true if and only if the current value is normal.
+ ///
+ /// This implies that the current value of the float is not zero, subnormal,
+ /// infinite, or NaN following the definition of normality from IEEE-754R.
+ ///
+ /// The current implementation of isNormal() differs from this by treating
+ /// subnormal values as normal values.
+ bool isIEEENormal() const { return !isDenormal() && isNormal(); }
+
+ /// Returns true if and only if the current value is zero, subnormal, or
+ /// normal.
+ ///
+ /// This means that the value is not infinite or NaN.
+ bool isFinite() const { return !isNaN() && !isInfinity(); }
+
+ /// Returns true if and only if the float is plus or minus zero.
+ bool isZero() const { return category == fcZero; }
+
+ /// IEEE-754R isSubnormal(): Returns true if and only if the float is a
+ /// denormal.
+ bool isDenormal() const;
+
+ /// IEEE-754R isInfinite(): Returns true if and only if the float is infinity.
+ bool isInfinity() const { return category == fcInfinity; }
+
+ /// Returns true if and only if the float is a quiet or signaling NaN.
+ bool isNaN() const { return category == fcNaN; }
+
+ /// Returns true if and only if the float is a signaling NaN.
+ bool isSignaling() const;
+
+ /// @}
+
/// \name Simple Queries
/// @{
fltCategory getCategory() const { return category; }
const fltSemantics &getSemantics() const { return *semantics; }
- bool isZero() const { return category == fcZero; }
bool isNonZero() const { return category != fcZero; }
bool isNormal() const { return category == fcNormal; }
- bool isNaN() const { return category == fcNaN; }
- bool isInfinity() const { return category == fcInfinity; }
- bool isNegative() const { return sign; }
bool isPosZero() const { return isZero() && !isNegative(); }
bool isNegZero() const { return isZero() && isNegative(); }
- bool isDenormal() const;
- /// IEEE-754R 5.7.2: isSignaling. Returns true if this is a signaling NaN.
- bool isSignaling() const;
/// @}