Why do you have to link the math library in C?

The functions in stdlib.h and stdio.h have implementations in libc.so (or libc.a for static linking), which is linked into your executable by default (as if -lc were specified). GCC can be instructed to avoid this automatic link with the -nostdlib or -nodefaultlibs options. The math functions in math.h have implementations in libm.so (or libm.a for … Read more

What is the difference between atan and atan2 in C++?

From school mathematics we know that the tangent has the definition tan(α) = sin(α) / cos(α) and we differentiate between four quadrants based on the angle that we supply to the functions. The sign of the sin, cos and tan have the following relationship (where we neglect the exact multiples of π/2): Quadrant Angle sin … Read more