-1.#IND000 can't be compared with 0.0

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

this problem happened after we upgrade our program from vc6.0 to vc.net2003
unmanaged code.

Following are the sample code:
float p, cpr = 3.4028234663852886e+038;
p = (1.0f - pow(1.0f-cpr/100.0f, 1.0f/12.0f));
if(p<0.0f)
p = 0.0;

==
Because the value of cpr is blow up during calculation, value p will be
-1.#IND000 after function call of the math function "pow".
In vc6.0, p<0.0f is true, and p=0.0 is executed, which is what we need. But
in vc.net 2003, p<0.0f is false.
I tried to compare p>0.0f, it is false too.

This is important because our system is big and there are many placed like
this in the program. we want the new system built under vc.net2003 behaves
the same way as it was before.

I checked the memory representation of the value of p. They are same for
version vc6.0 vs vc.net
"00 00 C0 FF"

But when it comes to the comparison statement, they behave differently.

Any feed back will be appreciated.

thanks.
Zongwen
 
Zongwen said:
this problem happened after we upgrade our program from vc6.0 to
vc.net2003 unmanaged code.

Following are the sample code:
float p, cpr = 3.4028234663852886e+038;
p = (1.0f - pow(1.0f-cpr/100.0f, 1.0f/12.0f));
if(p<0.0f)

if( p != p || p < 0.0f )

Will work for NAN's. I can't remember if -1.#IND000 represents a NAN.

Jeff Flinn
 
if( p != p || p < 0.0f ) works for me. Thanks.

But our problem is that we have so many uncertain places with same
situation. This doesn't happen in vc6.0, but apprears in vc.net. Do you know
this is because of the compiler difference? Is any control over compiler
option?

Thanks.
Zongwen
 
Back
Top