summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/APFloat.cpp
diff options
context:
space:
mode:
authorStephen Canon <scanon@apple.com>2015-11-16 21:52:48 +0000
committerStephen Canon <scanon@apple.com>2015-11-16 21:52:48 +0000
commit1bfc89baacea6f67beb0c13a8795f752577e1cc2 (patch)
tree0aad1e04eef67fac573ddecb48218e87bf99e86b /llvm/lib/Support/APFloat.cpp
parent927bdba29d5f0fbb6e98b204bdf0083e0dda7b62 (diff)
downloadbcm5719-llvm-1bfc89baacea6f67beb0c13a8795f752577e1cc2.tar.gz
bcm5719-llvm-1bfc89baacea6f67beb0c13a8795f752577e1cc2.zip
Add isInteger() to APFloat.
Useful utility function; this wasn't too hard to do before, but also wasn't obviously discoverable. Make it explicit. Reviewed offline by Michael Gottesman. llvm-svn: 253254
Diffstat (limited to 'llvm/lib/Support/APFloat.cpp')
-rw-r--r--llvm/lib/Support/APFloat.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index 91b3db59d0e..19b8221b60c 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -768,6 +768,15 @@ APFloat::isLargest() const {
}
bool
+APFloat::isInteger() const {
+ // This could be made more efficient; I'm going for obviously correct.
+ if (!isFinite()) return false;
+ APFloat truncated = *this;
+ truncated.roundToIntegral(rmTowardZero);
+ return compare(truncated) == cmpEqual;
+}
+
+bool
APFloat::bitwiseIsEqual(const APFloat &rhs) const {
if (this == &rhs)
return true;
OpenPOWER on IntegriCloud