Game Development Community

Calculating the Infinite (in my case: solved)

by rennie moffat · in iTorque 2D · 04/05/2011 (9:12 am) · 6 replies

Hi there,
I am wondering,
I am having a slight issue pop up in some calculations in that I get %variable == inf. I am wondering, if %variable == inf how can I say...

if(%variable == inf)
{
///do this.
}


Or if for what ever reason I can not get a return on the %variable. How can I put in preventive measures to abort the function if that is indeed the case? In other words, how can I say, if this the value is not a real number?







Cheers

About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
04/05/2011 (9:35 am)
This is a good question.
If a floating point number is greater than the maximal number or smaller than the minimal one,it is infinite for sure.

For floats the minimal one is FLT_MIN (10^(-37)),the maximal is FLT_MAX(10^37)
#2
04/05/2011 (9:43 am)
So a simple if with those values?


Will that account for the echo return of %value = inf?
#3
04/05/2011 (9:44 am)
function isInfinite(%var)
{
 // should return 'true' for infinite values
 return (%var <= mPow(10,-37)) || (%var >= mPow(10,37))
}

May be this should work.
#4
04/05/2011 (9:46 am)
Ok I will give it a try.

Thanks!





Infinitism, such an amazing thing.
#5
04/06/2011 (6:55 am)
Surely if a number is out of the usable range, you can't test against it because it can't be saved. I just did a test where I multiplied a large variable by itself a few times and echoed it. Eventually the echo turned into "1.#INF" so I guess that's Torque's way of saying infinite.
#6
04/06/2011 (7:47 am)
Hi,
well the glitch has seemed to cease, or at least been reduced in occurrences. What was causing it, was a parameter would go missing mid function. I just put up a "block", an if this is not true, right before the key calculation. And it went away. Yeh, new techniques everyday.



Thanks.