This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I still have trouble with FLOATFUZZY

My test routine is as follows.

#pragma OPTIMIZE(0)
#pragma FLOATFUZZY(3)
#include <intrins.h>

void main() {
  float f1;
  float f2;
  unsigned long l1;
  unsigned long l2;

  f1 = 0.9;
  f2 = f1 - 0.1;  // f2 = 0.8
  f1 = 0.8;	  // f1 = 0.8

  // Show the binary representations of the floats.
  l1 = *(unsigned long *)&f1;	// 0x3F4CCCCD
  l2 = *(unsigned long *)&f2;	// 0x3F4CCCCC

  if(f1 == f2) {  // not equal
    _nop_();
  }

  while(1);
}
I suppose that f1 and f2 would be equal after the three least significant bits of the mantissa are rounded. But the simulation turns out that they are not euqal.
I'm looking for your help.

d.curie