debugging
-
I've just started learning how to debug, and I'm still kinda new with C++ programming language. I have two variables declared as doubles: x, slope while debugging, I noticed that sometimes in the loop they're values came up as: slope = 1.#INF000000000 x = -1.#IND000000000 what does that mean?....why does it happen?
-
I've just started learning how to debug, and I'm still kinda new with C++ programming language. I have two variables declared as doubles: x, slope while debugging, I noticed that sometimes in the loop they're values came up as: slope = 1.#INF000000000 x = -1.#IND000000000 what does that mean?....why does it happen?
(EDIT: Corrections) 1.#INF stands for positive infinity. 1.#IND stands for positive ideterminite. If you add a negative, then they are negative infinity. This can happen if a variable has yet to be initialized. It can also happen during ASCII to float conversions and math operations. Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
-
I've just started learning how to debug, and I'm still kinda new with C++ programming language. I have two variables declared as doubles: x, slope while debugging, I noticed that sometimes in the loop they're values came up as: slope = 1.#INF000000000 x = -1.#IND000000000 what does that mean?....why does it happen?
1.#INF means positive infinity - usually you get it when you divide by zero. 1.#IND represents so-called 'quiet-nan' - for example, when you take the logarithm of negative value. Tomasz Sowinski -- http://www.shooltz.com
** If you're going to rape, pillage and burn, be sure to do things in that order. ** -
(EDIT: Corrections) 1.#INF stands for positive infinity. 1.#IND stands for positive ideterminite. If you add a negative, then they are negative infinity. This can happen if a variable has yet to be initialized. It can also happen during ASCII to float conversions and math operations. Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
-
1.#INF means positive infinity - usually you get it when you divide by zero. 1.#IND represents so-called 'quiet-nan' - for example, when you take the logarithm of negative value. Tomasz Sowinski -- http://www.shooltz.com
** If you're going to rape, pillage and burn, be sure to do things in that order. ** -
I've just started learning how to debug, and I'm still kinda new with C++ programming language. I have two variables declared as doubles: x, slope while debugging, I noticed that sometimes in the loop they're values came up as: slope = 1.#INF000000000 x = -1.#IND000000000 what does that mean?....why does it happen?
1.INF/-1.INF = Positive/Negative infinity 1.IND/-1.IND = Positive/Negative indeterminate 1.QNAN/-1.QNAN = Positive/Negative quiet not-a-number 1.NAN/-1.NAN = Positive/Negative not-a-number IEEE Reference information Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
-
So can I use that value just like other values in my code, for example in an if statement, could I say: if(x==1.#INF) { //do stuff } or when I say if(x>=9000) { //do stuff } will the infinite value be regarded as greater than 9000?
You can use _finite to test to see if a value is finite. Thus your NAN, QNAN, INF, IND should return false. (???) Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
-
So can I use that value just like other values in my code, for example in an if statement, could I say: if(x==1.#INF) { //do stuff } or when I say if(x>=9000) { //do stuff } will the infinite value be regarded as greater than 9000?
Don't - instead figure out what is setting the bad values. Those numbers indicate that you are doing something wrong. If the variables are uninitialized there is no guarantee that they will always be the same. If you are dividing by 0 or taking the log of a negative number you should be checking your inputs because they are faulty. Dave Huff There are no small projects - only young ones.