0

help please, why writes nan, and how to fix it?

#include <iostream> #include <math.h> using namespace std; const float a=2.05; double p(double k) { double p1; p1= (atan(k)+ (asin(a))/k); return(p1); } int main() { double x,y,z,F; cout<<"x="; cin>>x; cout<<"y="; cin>>y; cout<<"z="; cin>>z; F= log10( p(x) + p(y)) - log( p(z)); cout<<"F="<<F<<endl; return 0; }

26th Nov 2020, 10:25 PM
Имя Фамилия
Имя Фамилия - avatar
1 ответ
+ 2
NaN stands for Not a Number, in this case for example if x, y or z =0 you get a division by 0 that has undefined behavior
26th Nov 2020, 10:47 PM
Angelo
Angelo - avatar