Re: Can someone explain why this code outputs 7 ? (Is this a gcc bug?)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 4/23/2016 2:08 PM, Prathamesh Kulkarni wrote:
Please see:
[1] https://gcc.gnu.org/bugs/#nonbugs

This is not about the original question, but I happened to give a look at the 50/49 result example (first non-bug example). The explanation is obviously correct about rounding of finite precision numbers, but I think it could more clearly say that it is the combined result of rounding of floating point operations and /truncation/ (as per C/C++ standard) of double to int conversion: if the (int) cast were not in place the result would always be 50 because the << operator on double would round the output to 50.

--
Manfred



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux