# Thread: double, NaN, and super small numbers

1. ## double, NaN, and super small numbers

Hi All,
I need a quick answer, I have a function that returns a double, the formula becomes super small and eventually becomes less tan 10^-308, and then it returns NaN instead of 0, Once my function is ~10^-10 for my purposes is zero, How do I get it to return 0 if it's less than a certain value or if it is NaN I would like to to return 0. Thanks 2. Originally Posted by nbo10 Hi All,
I need a quick answer, I have a function that returns a double, the formula becomes super small and eventually becomes less tan 10^-308, and then it returns NaN instead of 0, Once my function is ~10^-10 for my purposes is zero, How do I get it to return 0 if it's less than a certain value or if it is NaN I would like to to return 0. Thanks
Just a little bit of rewording:
Code:
```if (function value is less than 'certain value') or (function value is NaN)
return 0;
return function value;```
I mean, by asking the question, you've practically got the pseudo-code for it. 3. So how would I code to check if a double is NaN? 4. Code:
```float x;
isnan(x);
or in microsoft compiler:
_isnan(x);```
--
Mats 5. Thanks I was trying x=='NaN' and it wasn't working.

isnan works great. thanks 6. I believe you can also use other tests like if (!(x==x)) to check for nans. Popular pages Recent additions 