PDA

View Full Version : clarification



andrewgosline
01-14-2003, 11:41 AM
So, if I use a floating point value of 3.123409 or any value with a decimal place in it, it will come back as some thing slightly different, like 3.123383. However, if I specify 2.0 or -3.0. Then I get back exactly 2.0 or 3.0 when I glreadpixels the pbuffer.

andrewgosline
01-14-2003, 11:45 AM
never mind this, it should be under the "Enabling Blend when rendering to a pbuffer" discussion topic. I pressed the wrong button... oops, sorry!

HS
01-14-2003, 11:53 AM
Check the IEEE specifications on floating point numbers.

Calculated floating point numbers are inaccurate by definition.

NEVER check if an calculated value equals an specified value like:





float aValue = sin(something*3.1415*whatever);

if( aValue == 1.0f)
{
...
}



The 'if' will fail for a lot of cases where it mathematicaly should not.

IEEE floating point numbers are just a fast approximation.

Hope that shed some light on the topic.