# C++ equivalent of NumPy/PHP rad2deg

In order to convert radians to degrees, PHP provides the rad2deg function whereas Python’s NumPy library provides np.rad2deg.

In C++ there is no standard function to convert radians to degrees.

However, you can use this simple snippet:

#define _USE_MATH_DEFINES
#include <cmath>

/**
* Convert the angle given in radians to degrees.
*/
template<typename F>
}
This will work for double, float etc. and returns the angle in degrees.
$$\text{Degrees} = \frac{\text{Radians} \cdot 180°}{\pi}$$