<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">I have reverted this patch in r189447 to please the buildbots.<div><br><div><div>On Aug 27, 2013, at 11:17 PM, Charles Davis <<a href="mailto:cdavis5x@gmail.com">cdavis5x@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br>On Aug 27, 2013, at 11:23 PM, Eli Friedman wrote:<br><br><blockquote type="cite">Author: efriedma<br>Date: Wed Aug 28 00:23:51 2013<br>New Revision: 189442<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=189442&view=rev">http://llvm.org/viewvc/llvm-project?rev=189442&view=rev</a><br>Log:<br>Change default # of digits for APFloat::toString<br><br>The previous default was almost, but not quite enough digits to<br>represent a floating-point value in a manner which preserves the<br>representation when it's read back in.  The larger default is much<br>less confusing.<br><br>I spent some time looking into printing exactly the right number of<br>digits if a precision isn't specified, but it's kind of complicated,<br>and I'm not really sure I understand what APFloat::toString is supposed<br>to output for FormatPrecision != 0 (or maybe the current API specification<br>is just silly, not sure which).  I have a WIP patch if anyone is interested.<br></blockquote>This is causing (I believe) the following Clang test failures for at least me:<br><br>   Clang :: CXX/expr/expr.const/p2-0x.cpp<br>   Clang :: CXX/temp/temp.spec/p5.cpp<br>   Clang :: PCH/exprs.c<br>   Clang :: PCH/floating-literal.c<br>   Clang :: PCH/objc_literals.m<br>   Clang :: Rewriter/objc-modern-boxing.mm<br>   Clang :: Rewriter/objc-modern-numeric-literal.mm<br>   Clang :: Sema/array-init.c<br>   Clang :: Sema/knr-def-call.c<br>   Clang :: SemaCXX/warn-literal-conversion.cpp<br>   Clang :: SemaTemplate/member-template-access-expr.cpp<br><br>As far as I can tell, all the failures are caused by the greater precision printed out. Here's the output from the first one:<br><br>FAIL: Clang :: CXX/expr/expr.const/p2-0x.cpp (603 of 15277)<br>******************** TEST 'Clang :: CXX/expr/expr.const/p2-0x.cpp' FAILED ********************<br>Script:<br>--<br>/Users/chip/llvm-git/build1/Release+Asserts/bin/clang -cc1 -internal-isystem /Users/chip/llvm-git/build1/Release+Asserts/bin/../lib/clang/3.4/include -fsyntax-only -std=c++11 -pedantic -verify -fcxx-exceptions /Users/chip/llvm-git/tools/clang/test/CXX/expr/expr.const/p2-0x.cpp -fconstexpr-depth 128 -triple i686-pc-linux-gnu<br>--<br>Exit Code: 1<br><br>Command Output (stderr):<br>--<br>error: 'note' diagnostics expected but not seen:<br> File /Users/chip/llvm-git/tools/clang/test/CXX/expr/expr.const/p2-0x.cpp Line 139: value 1.0E+300 is outside the range of representable values of type 'float'<br>error: 'note' diagnostics seen but not expected:<br> File /Users/chip/llvm-git/tools/clang/test/CXX/expr/expr.const/p2-0x.cpp Line 139: value 1.0000000000000001E+300 is outside the range of representable values of type 'float'<br>2 errors generated.<br><br>--<br><br>Did you remember to also update Clang?<br><br>Chip<br><br><blockquote type="cite"><br>Modified:<br>  llvm/trunk/lib/Support/APFloat.cpp<br>  llvm/trunk/unittests/ADT/APFloatTest.cpp<br><br>Modified: llvm/trunk/lib/Support/APFloat.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=189442&r1=189441&r2=189442&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=189442&r1=189441&r2=189442&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/Support/APFloat.cpp (original)<br>+++ llvm/trunk/lib/Support/APFloat.cpp Wed Aug 28 00:23:51 2013<br>@@ -3546,11 +3546,14 @@ void APFloat::toString(SmallVectorImpl<c<br> // Set FormatPrecision if zero.  We want to do this before we<br> // truncate trailing zeros, as those are part of the precision.<br> if (!FormatPrecision) {<br>-    // It's an interesting question whether to use the nominal<br>-    // precision or the active precision here for denormals.<br>+    // We use enough digits so the number can be round-tripped back to an<br>+    // APFloat. The formula comes from "How to Print Floating-Point Numbers<br>+    // Accurately" by Steele and White.<br>+    // FIXME: Using a formula based purely on the precision is conservative;<br>+    // we can print fewer digits depending on the actual value being printed.<br><br>-    // FormatPrecision = ceil(significandBits / lg_2(10))<br>-    FormatPrecision = (semantics->precision * 59 + 195) / 196;<br>+    // FormatPrecision = 2 + floor(significandBits / lg_2(10))<br>+    FormatPrecision = 2 + semantics->precision * 59 / 196;<br> }<br><br> // Ignore trailing binary zeros.<br><br>Modified: llvm/trunk/unittests/ADT/APFloatTest.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/APFloatTest.cpp?rev=189442&r1=189441&r2=189442&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/APFloatTest.cpp?rev=189442&r1=189441&r2=189442&view=diff</a><br>==============================================================================<br>--- llvm/trunk/unittests/ADT/APFloatTest.cpp (original)<br>+++ llvm/trunk/unittests/ADT/APFloatTest.cpp Wed Aug 28 00:23:51 2013<br>@@ -866,10 +866,11 @@ TEST(APFloatTest, toString) {<br> ASSERT_EQ("0.0101", convertToString(1.01E-2, 5, 2));<br> ASSERT_EQ("0.0101", convertToString(1.01E-2, 4, 2));<br> ASSERT_EQ("1.01E-2", convertToString(1.01E-2, 5, 1));<br>-  ASSERT_EQ("0.7853981633974483", convertToString(0.78539816339744830961, 0, 3));<br>-  ASSERT_EQ("4.940656458412465E-324", convertToString(4.9406564584124654e-324, 0, 3));<br>-  ASSERT_EQ("873.1834", convertToString(873.1834, 0, 1));<br>-  ASSERT_EQ("8.731834E+2", convertToString(873.1834, 0, 0));<br>+  ASSERT_EQ("0.78539816339744828", convertToString(0.78539816339744830961, 0, 3));<br>+  ASSERT_EQ("4.9406564584124654E-324", convertToString(4.9406564584124654e-324, 0, 3));<br>+  ASSERT_EQ("873.18340000000001", convertToString(873.1834, 0, 1));<br>+  ASSERT_EQ("8.7318340000000001E+2", convertToString(873.1834, 0, 0));<br>+  ASSERT_EQ("1.7976931348623157E+308", convertToString(1.7976931348623157E+308, 0, 0));<br>}<br><br>TEST(APFloatTest, toInteger) {<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">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br></blockquote><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">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></blockquote></div><br></div></body></html>