On Jun 2, 2014, at 10:06 AM, Vincent Lefevre <vincent+...@vinc17.org> wrote:
> I've looked at > > https://gcc.gnu.org/wiki/FloatingPointMath > > and there may be some mistakes or missing info. That’s quite possible. I created the page many years ago, based on my understanding of GCC at that time. > > First, it is said that x / C is replaced by x * (1.0 / C) when C is > a power of two. But this condition is not sufficient: if 1.0 / C > overflows, the transformation is incorrect. From some testing, > it seems that GCC detects the overflow case, so that it behaves > correctly. In this case I think that the wiki should say: > "When C is a power of two and 1.0 / C doesn't overflow.” Yes, that was implied, but should indeed be made explicit. > > It is also said that x / 1.0 and x / -1.0 are respectively replaced > by x and -x. But what about x * 1.0 and x * -1.0? > > Ditto with -(a / b) -> a / -b and -(a / b) -> -a / b. Is there > anything similar with multiplication? It should, or it would be a bug. Please feel free to add/correct anything on this page. -Geert