#4
Code:

#import <Foundation/Foundation.h>
#import <math.h>
float RadiantoDegree(float radian)
{
return ((radian / M_PI) * 180.0f);
}
float DegreetoRadian(float degree)
{
return ((degree / 180.0f) * M_PI);
}
int main (int argc, const char * argv[])
{
@autoreleasepool {
float radian, degree;
degree = RadiantoDegree(radian);
radian = DegreetoRadian(degree);
}
return 0;
}

#7
How about:

double Radians(double x) /*decimal degrees to radians*/

{

return(x * 0.017453293);

}

double Degrees(double x) /*converts radians to decimal degrees*/

{

return(x * 57.29577952);

}

or:

//M_PI defined in math.h:

#include <math.h>

double decimalDegreesToRadians(double x)

{

return(x/360.0 * (2.0 * M_PI));

}

double radiansToDecimalDegrees(double x)

{

return(x / (2.0 * M_PI) * 360.0);

}

You could optimize the second two functions by replacing the (2.0 * M_PI) with 6.2831853071795862. I just copied the first two functions from an astronomy program, so check to see if they're correct. If a type double is the default floating point type for your processor you should do the calculations as a double. There would be no performance advantage in using a smaller type such as a float.