Today it took me a lot of time to find a bug in a VBA macro. I just didn't understand why the function atan2(a,b) cannot return the correct answer.
After carefully reading the description of this function in the Microsoft Visual Basic Help, I realized that I mistakenly assumed that the atan2() in VBA (worksheet functions) is the same as the atan2() in c++. I was wrong!!
In Excel Developer Reference:
Atan2(x,y)
returns the arctangent of the specified x and y coordinates.
In C++ Developer Reference:
C Library, cmath (math.h)
double atan2 ( double y, double x );y: Floating point value representing an y-coordinate.
long double atan2 ( long double y, long double x );
float atan2 ( float y, float x );
x: Floating point value representing an x-coordinate
Difference:
See?! The meanings of the first and the second parameters in C++ are switched in VBA!!
No comments:
Post a Comment