summaryrefslogtreecommitdiff
path: root/unittests/ADT/APFloatTest.cpp
Commit message (Collapse)AuthorAge
* [C++11] Use 'nullptr'.Craig Topper2014-06-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210442 91177308-0d34-0410-b5e6-96231b3b80d8
* APFloat: x - NaN needs to flip the signbit of NaN when x is a number.Stephen Canon2014-06-08
| | | | | | Because we don't have a separate negate( ) function, 0 - NaN does double-duty as the IEEE-754 negate( ) operation, which (unlike most FP ops) *does* attach semantic meaning to the signbit of NaN. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210428 91177308-0d34-0410-b5e6-96231b3b80d8
* Change default # of digits for APFloat::toStringEli Friedman2013-08-29
| | | | | | | | | | | | | | | | | This is a re-commit of r189442; I'll follow up with clang changes. The previous default was almost, but not quite enough digits to represent a floating-point value in a manner which preserves the representation when it's read back in. The larger default is much less confusing. I spent some time looking into printing exactly the right number of digits if a precision isn't specified, but it's kind of complicated, and I'm not really sure I understand what APFloat::toString is supposed to output for FormatPrecision != 0 (or maybe the current API specification is just silly, not sure which). I have a WIP patch if anyone is interested. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189624 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r189442 "Change default # of digits for APFloat::toString"Ted Kremenek2013-08-28
| | | | | | This is breaking numerous Clang tests on the buildbot. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189447 91177308-0d34-0410-b5e6-96231b3b80d8
* Change default # of digits for APFloat::toStringEli Friedman2013-08-28
| | | | | | | | | | | | | | | The previous default was almost, but not quite enough digits to represent a floating-point value in a manner which preserves the representation when it's read back in. The larger default is much less confusing. I spent some time looking into printing exactly the right number of digits if a precision isn't specified, but it's kind of complicated, and I'm not really sure I understand what APFloat::toString is supposed to output for FormatPrecision != 0 (or maybe the current API specification is just silly, not sure which). I have a WIP patch if anyone is interested. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189442 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Make all arithmetic operations with NaN produce positive NaNs.Michael Gottesman2013-07-27
| | | | | | | | | | | | | IEEE-754R 1.4 Exclusions states that IEEE-754R does not specify the interpretation of the sign of NaNs. In order to remove an irrelevant variable that most floating point implementations do not use, standardize add, sub, mul, div, mod so that operating anything with NaN always yields a positive NaN. In a later commit I am going to update the APIs for creating NaNs so that one can not even create a negative NaN. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187314 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle '.' correctly in hex float literal parsing.Eli Friedman2013-07-17
| | | | | | | | | | | There were a couple of different loops that were not handling '.' correctly in APFloat::convertFromHexadecimalString; these mistakes could lead to assertion failures and incorrect rounding for overlong hex float literals. Fixes PR16643. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186539 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Ensure that we can properly parse strings that do not have null ↵Michael Gottesman2013-07-01
| | | | | | | | terminators. rdar://14323230 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185397 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Added unittest for APFloat.divide that checks special cases, ↵Michael Gottesman2013-06-27
| | | | | | result categories, and result statuses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185050 91177308-0d34-0410-b5e6-96231b3b80d8
* Removed two logging printf statements from the APFloat tests... = /.Michael Gottesman2013-06-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185045 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Added unittest for APFloat.multiply that checks special cases, ↵Michael Gottesman2013-06-26
| | | | | | result categories, and result status. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185044 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Added unittest for APFloat.subtract that checks special cases, ↵Michael Gottesman2013-06-26
| | | | | | result categories, and result status. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185043 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Removed debugging cruft that snuck in.Michael Gottesman2013-06-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184974 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Removed trailing whitespace from unittests.Michael Gottesman2013-06-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184715 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Added a large unittest for APFloat.add that checks that special ↵Michael Gottesman2013-06-24
| | | | | | values are computed correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184714 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Rename isIEEENormal => isNormal and remove old isNormal method.Michael Gottesman2013-06-20
| | | | | | | | The old isNormal is already functionally replaced by the method isFiniteNonZero in r184350 and all references to said method were replaced in LLVM/clang in r184356/134366. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184449 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Fix typo in test so we actually test if we handle denormals.Michael Gottesman2013-06-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184447 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Changed APFloat::isNormal => APFloat::isFiniteNonZero for all ↵Michael Gottesman2013-06-19
| | | | | | | | tests in unittests. I forgot to to do this in r184356. The only references were in APFloatTest.cpp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184366 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Added isFiniteNonZero predicate.Michael Gottesman2013-06-19
| | | | | | | | | | | | | | | | | This is the first patch in a series of patches to rename isNormal => isFiniteNonZero and isIEEENormal => isNormal. In order to prevent careless errors on my part the overall plan is: 1. Add the isFiniteNonZero predicate with tests. I can do this in a method independent of isNormal. (This step is this patch). 2. Convert all references to isNormal with isFiniteNonZero. My plan is to comment out isNormal locally and continually convert isNormal references => isFiniteNonZero until llvm/clang compiles. 3. Remove old isNormal and rename isIEEENormal to isNormal. 4. Look through all of said references from patch 2 and see if we can simplify them by using the new isNormal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184350 91177308-0d34-0410-b5e6-96231b3b80d8
* IEEE-754R 5.7.2 General Operations is* operations (except for isCanonical).Michael Gottesman2013-06-04
| | | | | | | | | | | | | | | 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
* Try to avoid "integer literal too big" warnings from older GCCs.Benjamin Kramer2013-06-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183081 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Added a unittest for APFloat::getZero.Michael Gottesman2013-05-31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183028 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement IEEE-754R 2008 nextUp/nextDown functions in the guise of the ↵Michael Gottesman2013-05-30
| | | | | | | | function APFloat::next(bool nextDown). rdar://13852078 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182945 91177308-0d34-0410-b5e6-96231b3b80d8
* Added a unittest for APFloat::getSmallestNormalized.Michael Gottesman2013-05-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182897 91177308-0d34-0410-b5e6-96231b3b80d8
* Added code to the unittest for APFloat::getSmallest to double check that we ↵Michael Gottesman2013-05-30
| | | | | | | | | consider the result to be denormal. I additionally changed certain checks to use EXPECT_FALSE instead of a boolean complement with EXPECT_TRUE. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182896 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a unittest for APFloat::getSmallest.Michael Gottesman2013-05-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182894 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug that APFloat::fusedMultiplyAdd() mistakenly evaluate "14.5f * ↵Shuxin Yang2013-05-13
| | | | | | -14.5f + 225.0f" to 225.0f. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181715 91177308-0d34-0410-b5e6-96231b3b80d8
* APFloat: Make sure that we get a well-formed x87 NaN when converting from a ↵Benjamin Kramer2013-01-25
| | | | | | | | smaller type. Fixes PR15054. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173459 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement APFloat::isDenormal()Shuxin Yang2013-01-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171764 91177308-0d34-0410-b5e6-96231b3b80d8
* Sort the #include lines for unittest/...Chandler Carruth2012-12-04
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169250 91177308-0d34-0410-b5e6-96231b3b80d8
* Drop the limitation to IEEE floating point types from the fdiv of pow2 -> ↵Benjamin Kramer2012-11-08
| | | | | | | | fmul transform. This is safe for x87 long doubles and ppc double doubles too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167582 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement arithmetic on APFloat with PPCDoubleDouble semantics byUlrich Weigand2012-10-29
| | | | | | | | | | | | | treating it as if it were an IEEE floating-point type with 106-bit mantissa. This makes compile-time arithmetic on "long double" for PowerPC in clang (in particular parsing of floating point constants) work, and fixes all "long double" related failures in the test suite. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166951 91177308-0d34-0410-b5e6-96231b3b80d8
* APFloat::roundToIntegral: Special values don't keep the exponent value up to ↵Benjamin Kramer2012-09-26
| | | | | | | | date, don't rely on it. Add a couple of unit tests for special floats. Fixes 13929, found by MemorySanitizer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164698 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix another roundToIntegral bug where very large values could become ↵Owen Anderson2012-08-15
| | | | | | infinity. Problem and solution identified by Steve Canon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161969 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a problem with APFloat::roundToIntegral where it would return incorrect ↵Owen Anderson2012-08-15
| | | | | | results for negative inputs to trunc. Add unit tests to verify this behavior. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161929 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix APFloat::convert so that it handles narrowing conversions correctly; itEli Friedman2011-11-26
| | | | | | | | | | was returning incorrect values in rare cases, and incorrectly marking exact conversions as inexact in some more common cases. Fixes PR11406, and a missed optimization in test/CodeGen/X86/fp-stack-O0.ll. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145141 91177308-0d34-0410-b5e6-96231b3b80d8
* Attempt to fix MSVC build.Eli Friedman2011-10-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141831 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix APFloat::getLargest so that it actually returns the correct value. ↵Eli Friedman2011-10-12
| | | | | | Found by accident while reviewing a patch to nearby code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141816 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a test that wasn't testing the right thing.Matt Beaumont-Gay2011-08-29
| | | | | | | | The APFloat "Zero" test was actually calling the APFloat(const fltSemantics &, integerPart) constructor, and EXPECT_EQ was treating 0 and -0 as equal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138745 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an APFloat::convertToInt(APSInt) function that automatically manages theJeffrey Yasskin2011-07-15
| | | | | | memory for the result. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135259 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid turning a floating point division with a constant power of two into a ↵Benjamin Kramer2011-03-30
| | | | | | | | | denormal multiplication. Some platforms may treat denormals as zero, on other platforms multiplication with a subnormal is slower than dividing by a normal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128555 91177308-0d34-0410-b5e6-96231b3b80d8
* Add APFloat::getExactInverse.Benjamin Kramer2011-03-30
| | | | | | | | | | | | | | The idea is, that if an ieee 754 float is divided by a power of two, we can turn the division into a cheaper multiplication. This function sees if we can get an exact multiplicative inverse for a divisor and returns it if possible. This is the hard part of PR9587. I tested many inputs against llvm-gcc's frotend implementation of this optimization and didn't find any difference. However, floating point is the land of weird edge cases, so any review would be appreciated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128545 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix death tests in -Asserts builds.Jeffrey Yasskin2010-03-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98701 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach APFloat how to create both QNaNs and SNaNs and with arbitrary-widthJohn McCall2010-02-28
| | | | | | | | | | payloads. APFloat's internal folding routines always make QNaNs now, instead of sometimes making QNaNs and sometimes SNaNs depending on the type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97364 91177308-0d34-0410-b5e6-96231b3b80d8
* Make APFloat's string-parsing routines a bit safer against very large exponents.John McCall2010-02-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97278 91177308-0d34-0410-b5e6-96231b3b80d8
* Make APInt::countLeadingZerosSlowCase() treat the contents of padding bitsJohn McCall2010-02-03
| | | | | | | | as undefined. Fixes an assertion in APFloat::toString noticed by Dale. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95196 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement support for converting to string at "natural precision", and fix someJohn McCall2009-12-24
| | | | | | | | major bugs in long-precision conversion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92150 91177308-0d34-0410-b5e6-96231b3b80d8
* Add accessors for the largest-magnitude, smallest-magnitude, andJohn McCall2009-12-24
| | | | | | | | | | smallest-normalized-magnitude values in a given FP semantics. Provide an APFloat-to-string conversion which I am quite ready to admit could be much more efficient. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92126 91177308-0d34-0410-b5e6-96231b3b80d8
* Add test for PR4873, which works for me.Daniel Dunbar2009-09-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80965 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for including '+' in APFloat strings, more asserts,Erick Tryzelaar2009-08-20
| | | | | | and many new unit tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79574 91177308-0d34-0410-b5e6-96231b3b80d8