This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: rs6000: floating point cast oddities?


On Mon, Dec 17, 2001 at 11:35:46AM -0800, Linus Torvalds wrote:
> If the architecture does IEEE fp for floats, I thought the following
> held true:
> 
>   (float)(float + float) = (float)((double)float + (double)float)
> 
> including all the overflow and special cases.

I'd have thought there were possible double rounding issues,
but a brute-force search across a problem range I suspected
didn't yield any differences.

Anyone know for absolute certain here?


r~


main()
{
  union {
    float f;
    unsigned int i;
  } u, x, y;

  unsigned int i;

  for (i = 0x4b8ffff0; i < 0x4c00000f; ++i)
    {
      u.i = i;
      x.f = u.f + 0.5f;
      y.f = (double)u.f + 0.5;
      if (x.i != y.i)
        printf("%08x  %08x\n", x.i, y.i);
    }

  return 0;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]