Skip to main content
gamedev.net
🔒 Locked

FLT_EPSILON

Started by papa Apr 27, 2004 at 5:19 AM 2 replies 7.4k views
Original Post
papa
papa
Hi I dont quite understand why FLT_EPSILON contains 1.19209290E-07F. It says that its the smallest positive value so why it starts with 1.1 I've done a simple meaningless test which fails. why? float smallest = FLT_EPSILON; if( smallest < 0.0000001f ) { // It never gets here? why I thought 0.0000001f is still positive and smaller value could be 0.00000001f (one more zero) } so if FLT_EPSILON is the smallest positive value why the if() fails? Is it something to do with the float precission. Obviously I dont understand this clearly can you please explain. I am basically trying to determine if some float X value is not 0.0f but can be near zero before rounding errors occur. Second question.. Would it be actually correct to use epsilon for this case. Is it right test I am doing? Thank you. [edited by - papa on April 27, 2004 6:22:09 AM]
vicviper
vicviper

I''m guessing the reason for this is that Epsilon is commonly used as a test previous an operation that could fail if the values are too low.

So, if you want to do a division, you can test the values against epsilon, and know if the result of the operation will be reasonably accurate or not.
papa
papa
ok. Yes that could be one of the example. But to me 0.0000001f isn't complete 0.0f value. Why the above if statement fails?

Question:
What kind of representation 1.19209290E-07F is that suggests that is smaller than foe eg. 0.0001 or 0.00001?

why it fails once is below 0.0000001f?

[edited by - papa on April 27, 2004 6:44:16 AM]
Jingo
Jingo
Your number is

0.0000001

smallest is

0.00000011920929

Which is bigger than your value. So smallest < 0.0000001f is false.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.