From 1f54f58e64314601de1a082383e84162b287cab9 Mon Sep 17 00:00:00 2001 From: Dale Johannesen Date: Mon, 19 Jan 2009 21:17:05 +0000 Subject: compile-time fmod was done incorrectly. PR 3316. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62528 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/APFloat.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/Support/APFloat.cpp') diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp index 4da7144198..fde157d60f 100644 --- a/lib/Support/APFloat.cpp +++ b/lib/Support/APFloat.cpp @@ -1531,7 +1531,7 @@ APFloat::mod(const APFloat &rhs, roundingMode rounding_mode) integerPart *x = new integerPart[parts]; bool ignored; fs = V.convertToInteger(x, parts * integerPartWidth, true, - rmNearestTiesToEven, &ignored); + rmTowardZero, &ignored); if (fs==opInvalidOp) return fs; @@ -1811,7 +1811,9 @@ APFloat::convertToSignExtendedInteger(integerPart *parts, unsigned int width, if (exponent < 0) { /* Our absolute value is less than one; truncate everything. */ APInt::tcSet(parts, 0, dstPartsCount); - truncatedBits = semantics->precision; + /* For exponent -1 the integer bit represents .5, look at that. + For smaller exponents leftmost truncated bit is 0. */ + truncatedBits = semantics->precision -1U - exponent; } else { /* We want the most significant (exponent + 1) bits; the rest are truncated. */ -- cgit v1.2.3-18-g5258