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

Floating Point Arithmetic Bug?

I am experiencing unexpected results when performing floating point arithmetic.

void main( void )
{
long raw_value;
float scaling_factor = 0.0762951;
float scaling_offset = -1000;
float result;

for( raw_value = 65530; raw_value <= 65535; raw_value++ )
{
   result = ( raw_value * scaling_factor ) + scaling_offset;
}

}

This example gives the following results:
Raw=65530 Result=3999.617
Raw=65531 Result=3999.694
Raw=65532 Result=3999.770
Raw=65533 Result=3999.846
Raw=65534 Result=3999.922
Raw=65535 Result=4999.999 // This is incorrect

Parents Reply Children
No data