Trig. Functions and Small numbers

I am having problems finding sin(<a small number>)
I just want sin(z=0.19...) coming from an operation sin( 0 + (1/2)) * (pi/(2*M))
The real calculator value in radians should be 0.something, but I get 0 as output.

Is this a cout problem? Or, really a computation roundoff problem?
1
2
3
4
5
6
7
8
9
10
11
12
double pi = 3.1416; // according to matlab output
 28         // if(type == 0 )
 29         // {
 30                 /* MLT case 
 31                  * hp_s[i] = 1/sqrt(2*M) * sin(   ( (0:2*M-1) + 1/2)  *pi/(2*M)).'; */
 32                 for (int i =0; i <= (2*M)-1 ; i++ )
 33                         hp_s.push_back(  (1/sqrt(2*M)) * sin( ( i + (1/2))  * (pi/(2*M))) );
 34 
 35                 cout <<" 1/sqrt(8) :  "<< (1/ (sqrt(2*M) )) <<"\n(1/2)*pi/8 : " << (1/2)*(pi/8) << "\nproduct in sine: "<<
 36                         sin(double( (1/2)*pi/8)  ) << "\nmanually: "<< sin(0.19634954084)<<"\n";
 37                 return hp_s;
1/2 == 0
integer division returns an integer
Last edited on
Thank you very much. I completely forgot about this. :/
Topic archived. No new replies allowed.