I’m getting a few nans for certain inputs into my kernel. I’ve tracked down the source of the nan to a multiplication, which has me a little confused. Here is the snippet I have for my debugging…
assert(!isinf(in[k][i]) && !isnan(in[k][i]));
assert(!isinf(in[k][j]) && !isnan(in[k][j]));
float value = in[k][i] * in[k][j];
if (isnan(value))
{
printf("%f * %f = %f\n", in[k][i], in[k][j], in[k][i] * in[k][j]);
}
assert(!isnan(value));
This produces the following output…
0.127511 * 0.000000 = nan
0.062237 * 0.000000 = nan
etc…
So it seems to me that I have two properly formatted floating point values, one of which is a zero, and their product is giving me a nan?? I’m clearly missing something.
Thanks for any help
Edit:
I’ve realised that I should just continue to backtrack through my algorithm but using “assert(!isnan(value * 10.0f))” as my test.
I guess now I’m interested to know how the value is secretly a nan but only realises it when you mutiply it by something, so I’ll leave this post here.