O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Code Sample 8.4: Degrees to Radians to Degrees

#define PI 3.14159265 // Since is not supplied...

double DegreesToRadians  ( double dDegrees )
{
  return dDegrees*(PI/180.0);  // Deg->Rad
}

double RadiansToDegrees ( double dRadians )
{
  return dRadians/(PI/180.0);  // Rad->Deg
}

Other complex math functions that are included in the library are:

p;sqrt ( <number> )               // calculate the square root
pow ( <number>, <exponent> )    // raises to exponent
log10 ( <number> )          // base 10 log of number

All of the arguments in the previous functions are double-precision floating-point (double) values. They also return double-precision floating-point values, which can be cast to integers if appropriate.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required