so I created a program that takes in two long double numbers and some a particular form of calculation on them. but the issue is, the output for me is inf or in some compilers, 0.. So the error only occurs when I enter exponential values like say I enter 1.11224e+2121 1.11224e+2121 then I get inf or 0 but if I get something like 2.4 5.9 I get proper value. How do I fix this?
here is my code
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main()
{
long double a,b,add=0,mean=0;
cin>>a>>b;
vector<long double> vector;
vector.push_back(a);
vector.push_back(b);
mean=(vector[0]+vector[1])/2;
for (int k = 0; k < 2; k++)
{
add= add+ pow((vector[k] - mean), 2);
}
cout<<add/2;
return 0;
}