I have written a function that calculates an area from coordinated stored in vector arrays:
void areaCalc(int corners, vector<float> x, vector<float> y, float& area)
{
float sum=0;
for (int i=0; i<=(corners-2); i++)
{
sum+=(((x[i])*(y[(i+1)]))-((x[(i+1)])*(y[i])));
}
sum+=(((x[(corners-1)])*(y[0]))-((x[0])*(y[(corners-1)])));
area=0.5*sum;
}
The problem is that when I compile it I get this warning from VC++:
warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
I can't figure out why this is happening as I haven't defined double as a data type anywhere in my program. This isn't a huge issue as the program still compiles and seems to run correctly but it still worries me that there is a warning.
Thanks for any help!