On 01/12/2026 18:22, Bonita Montero wrote:
> Am 01.12.2026 um 18:48 schrieb bartc:
>
>> I had the option to use either ° or 'deg':
>>
>> 15 deg
>
> How about that ?
>
> #include <iostream>
> #include <complex>
> #include <cmath>
>
> using namespace std;
>
> struct degree {};
>
> complex<double> operator *( double angle, degree )
> {
> return complex<double>( sin( angle ), cos( angle ) );
> }
>
> int main()
> {
> constexpr double Pi4 = 3.1415926535897932384626433832795 / 4.0;
> complex<double> dPi4 = Pi4 * degree();
> cout << abs( dPi4 ) << endl;
> }
>
I don't what you're trying to do here or what the purpose of 'complex' is.
Convert radians to degrees? Then this is an easier way to do it:
#define todegrees 57.2968
printf("%f\n", 3.14159 * todegrees); # display ~ 180
But my example went the other way: converting numeric literals representing degrees, into radians. So it would be done like this:
#define deg 0.01745329...
printf("%f\n", 180 * deg); # display pi