Math problem

Hi,

my problem is this:

double st;

st = 100 * sin(360 * (10000/23));

Now when my calculator is working in radians st is evaluated to 97% which is the value I'm after. When working in degrees it is approx -75% which is wrong. In Netbeans st is -75% like the wrong calculator value. How can I get 97% in Netbeans using the above formula?

What's wrong?

Any help appreciated.

FC.
I'm pretty sure the standard(?) has all the trigonomic functions using radians. However, if need be, you can convert from radians to degrees and vice versa:

rad = deg*pi/180
deg = rad*180/pi
Last edited on
Here's the example from the tutorial.
http://www.cplusplus.com/reference/cmath/sin/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* sin example */
#include <stdio.h>      /* printf */
#include <math.h>       /* sin */

#define PI 3.14159265

int main ()
{
  double param, result;
  param = 30.0;
  result = sin (param*PI/180);
  printf ("The sine of %f degrees is %f.\n", param, result );
  return 0;
}


Using pi/180 instead of 360 in your example gave me a result of 96.1262.
Last edited on
Topic archived. No new replies allowed.