<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Tianyou,<div class=""><br class=""></div><div class="">I am not enough of a physicist to know what “the qualification of the ground state energy in a quantum system” means, but this does not sound like a Clang bug to me. You did not say whether `a` in your example is a float or a double, but the minimum legal values for these types are the constants FLT_MIN and DBL_MIN. There is no need to try to compute them. Exceeding the range of values representable in a type — [FLT_MIN, FLT_MAX] or [DBL_MIN, DBL_MAX] — is undefined behavior, so the compiler is free to emit anything.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Matt<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On May 26, 2020, at 20:31, Tianyou via cfe-users <<a href="mailto:cfe-users@lists.llvm.org" class="">cfe-users@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=GB18030" class=""><div class=""><p style="margin-bottom: 0in; line-height: 16px; background-color: transparent;" class="">Hello everyone,</p><p style="margin-bottom: 0in; line-height: 16px; background-color: transparent;" class="">I found some questionable behaviors in the clang compiler.</p><p style="margin-bottom: 0in; line-height: 16px; background-color: transparent;" class="">I tried to calculate the smallest number in my machine with clang. I did it by looping as: </p><p style="margin-bottom: 0in; line-height: 16px; background-color: transparent;" class="">a = a / 1.73</p><p style="margin-bottom: 0in; line-height: 16px; background-color: transparent;" class="">In g++, after 1358 loops, I found that a = 4.94066E-324, and the value of a never changes from loop 1358 till the end 1500 loop.</p><p style="margin-bottom: 0in; line-height: 16px; background-color: transparent;" class="">It is questionable for me that a non zero real number here a = 4.94066E-324 divided by a non zero and non one real number here 1.73 will keep the same value. The phenomenon seems to the qualification of the ground state energy in a quantum system.</p><p style="margin-bottom: 0in; line-height: 16px; background-color: transparent;" class="">Is this bug for the clang compiler?</p><p style="margin-bottom: 0in; line-height: 16px; background-color: transparent;" class="">I tested my code with, g++ (Apple LLVM version 10.0.0, clang-1000.10.44.4) on Macintosh. I also tried a = a / 1.7, a = a / 1.77. </p><p style="margin-bottom: 0in; line-height: 16px; background-color: transparent;" class="">All have similar results. A ground state qualification and unchanged value of a. </p><p style="margin-bottom: 0in; line-height: 16px; background-color: transparent;" class="">I guess that it is related to the binary system used by the computer system. </p><p style="margin-bottom: 0in; line-height: 16px; background-color: transparent;" class="">Here with my codes. </p></div><div class=""><font face="楷体,楷体_GB2312" size="2" class=""><br class=""></font></div><div class=""><font face="楷体,楷体_GB2312" size="2" class="">Best wishes</font></div><div class=""><font face="楷体,楷体_GB2312" size="2" class="">Tianyou Yi</font></div><div class=""><font face="楷体,楷体_GB2312" size="2" class="">Postdoc researcher in National Tsing Hua University</font></div><div class=""><font face="楷体,楷体_GB2312" size="2" class=""><br class=""></font></div><div class=""><hr align="left" style="margin: 0 0 10px 0;border: 0;border-bottom:1px solid #E4E5E6;height:0;line-height:0;font-size:0;padding: 20px 0 0 0;width: 50px;" class=""><div style="font-size: 14px; font-family: Verdana;" class=""><div class=""><b class=""><font size="1" class="">Best wishes</font></b></div><div class=""><b class=""><font size="1" class="">Tianyou Yi</font></b> <br class=""></div><div class="">Please send me to </div><div class=""><a href="mailto:yitianyoucn@qq.com" class="">yitianyoucn@qq.com</a></div><div class=""><a href="mailto:yitianyou9711@gzemail.cn" class="">yitianyou9711@gzemail.cn</a></div><div class=""><br class=""></div><div class=""><br class=""></div>
</div></div><div class=""> </div>_______________________________________________<br class="">cfe-users mailing list<br class=""><a href="mailto:cfe-users@lists.llvm.org" class="">cfe-users@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users<br class=""></div></blockquote></div><br class=""></div></body></html>