Reputation: 144
How would I convert degrees to radians exactly. Rather than showing 0.785398
I want the program to show pi/4
.
I am currently using this script to convert degrees into radians.
cout << angle * M_PI / 180.0 << " radians";
Upvotes: 1
Views: 4069
Reputation: 218323
You might do
std::cout << angle / 180.0 << " pi radians";
Which will print
0.25 pi radians
You might be interested by how-to-convert-floats-to-human-readable-fractions to convert 0.25
into 1/4
.
Upvotes: 1