Using functions like sin, cos and tan declared in the <math.h> file returns the answer in radians, I need the answer in degrees. Some MSDN documentation told me to times radians by (180/pi) to convert them to degrees. However, this formula is not accurate when compared to the results given when calculating cos(30) for example with a calculator in RAD and then DEG mode.

How can I set the data format or result format for these functions, or more accurately convert the answer from RAD to DEG?

How can you possibly use ANY of these TRIG functions properly if you don't understand the relationship between DEGREES and RADIANS? This is so fundamental (and also so simple) that I'm not even going to give it to you.

But here is a hint: "How many degrees are there in a circle? Ok, how many radians are there in a circle?"

If you know these two things you can derive the relationship.

This is basic (8th Grade around here) algebra!!!

By the way, you have a 0.000 average here on EE when it comes to closing questions. Your question from Feb. 2002 is STILL OPEN:

x = pi / 2;
y = sin( x );
printf( "sin( %f ) = %f\n", x, y );
y = sinh( x );
printf( "sinh( %f ) = %f\n",x, y );
y = cos( x );
printf( "cos( %f ) = %f\n", x, y );
y = cosh( x );
printf( "cosh( %f ) = %f\n",x, y );
}

Your problem may have been that in your conversion formula, you were using integer values instead of double values, as jkr suggested.
To guarantee that all of the numerical constants you're using are interpreted as doubles, write

180.0L
instead of 180.0

The "L" postfix (double) and "F" postfix (float) let you satisfy C's nasty appetite for explicit instructions.

0

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

if u dont know the relation between radians and degrees
waste of using a computer to program.

0

josamotoAuthor Commented:

_uck all of you with your sarcastic insultent comments. First of all I KNOW THE DIFFERENCE BETWEEN DEGREES AND RADIANS, I HAVE THE FORMULAS OF CONVERSION FOR BOTH, maby you guys need to go and enhance your English comprehension skills, maby go back to creche to learn to "speek ingleesh!"

I didn't ask the for the formulas of conversion first of all, or at all the relation between degrees and radians. My question was concerning the accuracy obtained when using C functions, they are not the same as those values received when performing the exact formula with a scientific calculator!

To GregTooms, ten out of ten, thanks for your tip, as we can see, simple problems have often simple solutions!

0

josamotoAuthor Commented:

Thanx Greg, I'll keep your comment in mind whenever I use mathematical formulas in VC++ again.

You could email me at josamoto@hotmail.com, I'd like to know what your interests in programming are!

0

GregToombsCommented:

You're very welcome, and I emailed you.

0

Featured Post

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

But here is a hint: "How many degrees are there in a circle? Ok, how many radians are there in a circle?"

If you know these two things you can derive the relationship.

This is basic (8th Grade around here) algebra!!!

By the way, you have a 0.000 average here on EE when it comes to closing questions. Your question from Feb. 2002 is STILL OPEN:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=3dgames&qid=20263123

Please resolve this.