470,874 Members | 1,400 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,874 developers. It's quick & easy.

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

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
Apr 4 '06 #1
2 3729
Zongwen wrote:
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
Apr 5 '06 #2
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

"Jeff F" wrote:
Zongwen wrote:
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

Apr 5 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

73 posts views Thread by Claudio Grondi | last post: by
50 posts views Thread by diffuser78 | last post: by
5 posts views Thread by Brian | last post: by
6 posts views Thread by iCe CreaM | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.