I'm having a problem identifying a floating point exception.

Posted by Peter Stewart on Stack Overflow See other posts from Stack Overflow or by Peter Stewart
Published on 2010-06-15T16:28:11Z Indexed on 2010/06/15 16:32 UTC
Read the original article Hit count: 222

Filed under:
|
|

I'm using c++ in visual studio express to generate random expression trees for use in a genetic algorithm type of program.

Because they are random, the trees often generate (I'll call them exceptions, I'm not sure what they are)

Thanks to a suggestion by George, I turned the mask _MCW_EM on so that hardware interrupts are turned off. (the default)

So, the program runs uninterrupted, but some of the values returned are: -1.#INF, -1.#NAN, -1.#INV.

I don't know how to identify these so that I can throw an exeption:

if ( variable == -1.#INF) ??

DigitalRoss in this post seemed to have the solution, but as I understood it I couldn't make it work.

I've been looking all over the place for this simple bit of code, that I assumed would be used all

the time, but have had no luck.

thanks

© Stack Overflow or respective owner

Related posts about c++

Related posts about beginner