<p dir="ltr">For this and some of the other APFloat changes, I would really like to see unit tests. It seems especially important given the fragility of the APFloat class.</p>
<div class="gmail_quote">On Jul 27, 2013 2:53 PM, "Michael Gottesman" <<a href="mailto:mgottesman@apple.com">mgottesman@apple.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: mgottesman<br>
Date: Sat Jul 27 16:49:21 2013<br>
New Revision: 187313<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=187313&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=187313&view=rev</a><br>
Log:<br>
[APFloat] Move setting fcNormal in zeroSignificand() to calling code.<br>
<br>
Zeroing the significand of a floating point number does not necessarily cause a<br>
floating point number to become finite non zero. For instance, if one has a NaN,<br>
zeroing the significand will cause it to become +/- infinity.<br>
<br>
Modified:<br>
llvm/trunk/lib/Support/APFloat.cpp<br>
<br>
Modified: llvm/trunk/lib/Support/APFloat.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=187313&r1=187312&r2=187313&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=187313&r1=187312&r2=187313&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Support/APFloat.cpp (original)<br>
+++ llvm/trunk/lib/Support/APFloat.cpp Sat Jul 27 16:49:21 2013<br>
@@ -778,6 +778,7 @@ APFloat::bitwiseIsEqual(const APFloat &r<br>
APFloat::APFloat(const fltSemantics &ourSemantics, integerPart value) {<br>
initialize(&ourSemantics);<br>
sign = 0;<br>
+ category = fcNormal;<br>
zeroSignificand();<br>
exponent = ourSemantics.precision - 1;<br>
significandParts()[0] = value;<br>
@@ -845,7 +846,6 @@ APFloat::significandParts()<br>
void<br>
APFloat::zeroSignificand()<br>
{<br>
- category = fcNormal;<br>
APInt::tcSet(significandParts(), 0, partCount());<br>
}<br>
<br>
@@ -2301,9 +2301,9 @@ APFloat::convertFromHexadecimalString(St<br>
{<br>
lostFraction lost_fraction = lfExactlyZero;<br>
<br>
+ category = fcNormal;<br>
zeroSignificand();<br>
exponent = 0;<br>
- category = fcNormal;<br>
<br>
integerPart *significand = significandParts();<br>
unsigned partsCount = partCount();<br>
@@ -2512,6 +2512,7 @@ APFloat::convertFromDecimalString(String<br>
(D.normalizedExponent + 1) * 28738 <=<br>
8651 * (semantics->minExponent - (int) semantics->precision)) {<br>
/* Underflow to zero and round. */<br>
+ category = fcNormal;<br>
zeroSignificand();<br>
fs = normalize(rounding_mode, lfLessThanHalf);<br>
<br>
@@ -3398,6 +3399,7 @@ APFloat APFloat::getSmallestNormalized(c<br>
// exponent = 0..0<br>
// significand = 10..0<br>
<br>
+ Val.category = fcNormal;<br>
Val.zeroSignificand();<br>
Val.sign = Negative;<br>
Val.exponent = Sem.minExponent;<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>