none
trignometric ratios value RRS feed

  • Question

  • Hi All!

    i am trying to make a scientific calculator in windows form application using C# in visual studio 2010..in it there are buttons of sin, cos and tan..they give correct results for 30,45,60 and 180 degrees but cos 90 and tan 90 doesn't give correct answer...i am giving the code below...plz check it out and help me.......i'll be grateful to you..

    private void button10_Click(object sender, EventArgs e)
            {
                try
                {
                    Double a, result;
                    a = Convert.ToInt16(textBox1.Text);
                    result = Math.Sin(a * Math.PI / 180);
                    textBox3.Text = " " + result;
                }
                catch (Exception e1)
                {
                    MessageBox.Show(e1.Message);
                }
            }

            private void button12_Click(object sender, EventArgs e)
            {
                try
                {
                    Double a, result;
                    a = Convert.ToInt16(textBox1.Text);
                    result = Math.Tan(a * Math.PI / 180);
                    textBox3.Text = " " + result;
                }
                catch (Exception e1)
                {
                    MessageBox.Show(e1.Message);
                }
            }

            private void button11_Click(object sender, EventArgs e)
            {
                try
                {
                    Double a, result;
                    a = Convert.ToInt16(textBox1.Text);
                    result = Math.Cos(a * Math.PI / 180);
                    textBox3.Text = " " + result;
                }
                catch (Exception e1)
                {
                    MessageBox.Show(e1.Message);
                }
            } 

    Wednesday, July 18, 2012 6:31 PM

Answers

  • Hi,

    what's wrong with the values (tan 90 deg ->  1,63317787283838E+16 which seems to be correct in double precision, input "tan 90 degrees" into a google search mask to get their calculator result).

    Cos also seems alright with somewhat * e-17

    Regards,

      Thorsten


    Wednesday, July 18, 2012 8:28 PM