In my program I calculate two values (doubles) x and y and then find the number 1/(x^2 + y^2). My problem arises when x or y are so close to zero that the fraction gives a NaN. In reality, the fraction should give zero when both variables approach zero. I tried to use a comparison x==0 || y==0, but that doesn't work because they are doubles.
Is there a computationally effective method to take this into account?
#include <iostream>
using namespace std;
val(double x, double y)
{
    return 1/(x*x + y*y);
}
int main()
{
    //determine x and y....
    val(x, y)
    return 0;
}
 
     
     
     
    