Reasons for -1.#IND ?

For questions about using Classic.

Post » Wed Mar 25, 2009 4:57 pm

hi,
i am wondering about the possible ways to (inadvertendly) set a private variable to -1.#IND (undefined, i presume). i've got some simple TimeDelta-related math in a project, and it occasionally results in objects becoming invisible when their angle property is being calculated as -1.#IND
since the math is really simple, i've got no idea where to start looking. does somebody know the possible causes of this error?

( the cap is here. click & drag to scratch. occasionally bugs out, especially in debug mode & with unlimited framerate )
B
2
S
2
G
4
Posts: 171
Reputation: 1,792

Post » Wed Mar 25, 2009 4:59 pm

It means you've done something mathematically impossible. Like divide by zero, take the square root of a negative number, et cetera. The object disappears if the angle, width, height, x or y is this value, because it is impossible to determine how to render the object.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,610

Post » Wed Mar 25, 2009 5:03 pm

superfast! thank you very much! i'm guessing it is divide by zero, i'll have a close look.
B
2
S
2
G
4
Posts: 171
Reputation: 1,792

Post » Thu Mar 26, 2009 7:51 pm

A good way to fix a divide by zero is to ensure that the number you are dividing by is over 0 before performing the arithmetic operation by inserting a condition "Value to divide by > 0". This might be common sense, but this is a note for anyone else that gets stuck on this and can't figure it out.
B
2
G
3
Posts: 36
Reputation: 922


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests