Archived

This topic is now archived and is closed to further replies.

avoiding the dredded 1.#INF0

This topic is 5303 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello!! Im sure you have seen this before... y = (ax + cz + d) / b; When the b component is zero, we get into trouble. Is there a way of testing for 1.#INF0... like a function that goes "if y is infinite" in C++? Or are we just stuck to testing for 0 every time we go to divide? Cheeers

Share on other sites
Would it not be possible to check to see if b is zero BEFORE you put the variables into the equation, for it b is zero the outcome will be 1.#INFO??

It seems like the best solution to me, if it is fesible.

- Ratterbox

Share on other sites
Dreaded? *chuckle* NaNs are much worse

#include <limits>
if(result==std::numeric_limits<float>::infinity())
or
if(result==std::numeric_limits<double>::infinity())

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
— Brian W. Kernighan

Share on other sites
doh, i get this error.
error C2039: ''numeric_limits'' : is not a member of ''std''
is there a header im supposed to include?

Share on other sites
yes. Read my post more carefully.

Thankyou

Share on other sites
by the way, I think you are trying to work on planes, and you chose z and y as the parameters.
The best would be to choose the equation that does not involve singularities. since you can choose the x(y,z) and z(x,y) parameters instead, just pick the equation that works.
You can use templates to automatically formulate those equations.

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
14

• 14
• 10
• 23
• 9
• 32
• Forum Statistics

• Total Topics
632631
• Total Posts
3007532
• Who's Online (See full list)

There are no registered users currently online

×