<div dir="ltr"><div>Done in r189624.  (APFloat::toString really needs another look from someone who's really an expert at floating-point stuff, but at least the default behavior is sane.)</div><div><br></div><div>-Eli</div>
<br><div class="gmail_extra"><div class="gmail_quote">On Tue, Aug 27, 2013 at 9:53 AM, Will Wilson <span dir="ltr"><<a href="mailto:will@indefiant.com" target="_blank">will@indefiant.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr">I ended up with some nasty hacks to work around this issue, so if someone can fix it I'd be eternally grateful.</div><div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">On 27 August 2013 02:19, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I just hit this myself (months later!) trying to round-trip floats through strings. I don't think the problem is printed values exceeding their maximums so much as that APFloat::toString thinks the natural precision for DBL_MAX is one digit shorter than it actually is. I'll take a look, but someone with more floating-point experience might be able to get to the bottom of this sooner.</div>

<span><font color="#888888"><div><br></div><div>Jordan</div></font></span><div><div><div><br></div><br><div><div>On Apr 16, 2013, at 8:54 , Will Wilson <<a href="mailto:will@indefiant.com" target="_blank">will@indefiant.com</a>> wrote:</div>

<br><blockquote type="cite"><div dir="ltr">Sorry, I'm not being clear enough. It's nothing to do with runtime libs. Rather it's the result of printing out the expanded literal value directly from the AST. For instance:<div>

<ul>
<li>Clang parses the <span style="font-family:arial,sans-serif;font-size:13px">DBL_MAX macro into the AST (defined as 1.7976931348623158e+308)</span></li><li><font face="arial, sans-serif">Pretty printing out the FloatingLiteral results in: </font><span style="font-family:arial,sans-serif;font-size:13px">1.797693134862316E</span><span style="font-family:arial,sans-serif;font-size:13px">+</span><span style="font-family:arial,sans-serif;font-size:13px">308</span></li>


<li><font face="arial, sans-serif">Feeding these literals back to MSVC results in: error C2177: constant too big</font></li></ul></div><div>So my question is: Would it be sensible to try and ensure the printed values never exceed their maximums?</div>


<div><br></div><div>Cheers,</div><div>Will.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 16 April 2013 00:56, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><p dir="ltr"><br>
On Apr 16, 2013 8:01 AM, "Will Wilson" <<a href="mailto:will@indefiant.com" target="_blank">will@indefiant.com</a>> wrote:<br>
><br>
> Hi All,<br>
><br>
> I'm rewriting MS C++ code via clang and have an issue involving the printed representations of FLT_MAX and DBL_MAX. In both cases the printed literals exceed the inputs.<br>
><br>
> From MS float.h:<br>
><br>
> #define DBL_MAX         1.7976931348623158e+308<br>
> // Becomes 1.797693134862316E+308<br>
><br>
> #define FLT_MAX         3.402823466e+38F<br>
> // Becomes 3.4028235E+38F<br>
><br>
> Rewriting the values leads to compilation errors due to the literals exceeding their maximums. This doesn't altogether surprise me given the nature of FP arithmetic and string conversion but I was wondering if this could/should be treated as a bug given the significance of these values?</p>




</div></div><p dir="ltr">How are you printing these values out? Libstdc++ or libc++? Does the behavior reproduce under GCC too? I could guess/assume a bug in the standard library implementation you are using, but that's just a guess</p>


<div><div><p dir="ltr">><br>
> - Will.<br>
><br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
><br>
</p>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><span style="color:rgb(68,68,68);font-family:Arial,Helvetica,sans-serif"><b>Indefiant Ltd.</b></span></div><div>
<font color="#444444" face="Arial, Helvetica, sans-serif"><span style="font-size:12px"><b><br></b></span></font></div><font color="#444444" face="Arial, Helvetica, sans-serif">Firsby Lodge, New Main Road, Scamblesby, Louth, Lincs LN11 9XH UK<br>


</font><div style="padding:0px;margin:0px"><span style="color:rgb(68,68,68);font-family:Arial,Helvetica,sans-serif;font-size:x-small"><i>Tel: <a href="tel:%2B44%2020%208123%207663" value="+442081237663" target="_blank">+44 20 8123 7663</a> England Registered No. 07936820 VAT No. </i></span><span style="background-color:transparent"><font color="#444444" face="Arial, Helvetica, sans-serif" size="1"><i>128556202</i></font></span></div>



</div>
_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>

</blockquote></div><br></div></div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span class=""><font color="#888888">-- <br><div dir="ltr"><div><span style="color:rgb(68,68,68);font-family:Arial,Helvetica,sans-serif"><b>Indefiant Ltd.</b></span></div>

</div>
</font></span></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>