What the hell !? (EXCEPTION_FLT_INVALID_OPERATION)

Started by
5 comments, last by randomname 19 years, 7 months ago
I'm geting a EXCEPTION_FLT_INVALID_OPERATION exception. While comparing floats (exact compare):
if((f[lf-2]==a)&&(f[lf-1]==b)) { f[lf++]=c; return lf-3; }
// f is a array of floats. a,b are floats. lf is integer => nothing complex is going on.
and the instruction that triggers the exception:
fcomp dword ptr [ebp+0x0c]
No access violations anywhere (as seen in asm win - the target address is valid and exactly what i wanted to refer to). Intels 2.6GHz HT cpu. Google didn't help :( Any idea ? What could cause it ? And how to prevent it happening ?
Advertisement
Google pointed to a bug instead of an error.

If this wasn't what you're looking for, please provide tool information.
Yeah, saw that - some sql related stuff - not what i was looking for.

Anyway - after some minutes looking at the exception ... i got a idea:

Not all of the values i'm comparing are actually initialized (se, there is some random crap there) - that IS ok for ME, but NOT for mpu. I bet i did hit a float with the special value that means => 'NOT A FLOAT' => can't compare.

So, for the record: Initialize your floats before using them even if it is unneeded at your side (yeah, belive or not - i DIDN'T need them all to be initialized. LOL).

------------------
Problem solved.
Good find. You should always init your data structures to something, zero usually works.

Never leave random junk, or you'll get in over your head with errors as you just illustrated.

Cheers
Chris
Yeah.. uh... are you sure you should be using == with floats?
Ra
Quote:Original post by Ra
Yeah.. uh... are you sure you should be using == with floats?


Agreed. Very shaky ground there!
Comparing floats: LOL. Yeah, i do know what i'm doing ;)

A EXACT compare was needed. It is part of a code that was searching for a earlier instance of a float vector (no difference allowed). If not present, it gets added. So, '==' was what i needed.

Also, because not always did the vectors need to be initialized fully => garbage got into it. That is completly okay for me ... but ... you know the rest of the story. :)

This topic is closed to new replies.

Advertisement