+ Reply to Thread
Results 1 to 2 of 2

Thread: Math Calculation error

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    10

    Math Calculation error

    Hi , i am creating a calculator program but the Math.Sin() seem to generate some inaccurate results , here is my code :
    Code:
        private void bSin_Click(object sender, EventArgs e)
        {
            if (radioDeg.Checked)
            {
                firstOperand = Math.PI/180*firstOperand;
            }
            firstOperand = Math.Sin(firstOperand);
            secondOperand = 0;
            displayScreen.Text = firstOperand.ToString();
            clickCount = 0;
            operationCount++;
        }
    When Math.Sin(Math.PI) the result =1.224 instead of 0 as it should be , i tried to work that problem out , but could not , hope you guys help me with that

  2. #2
    Hello sarah , welcome to the forum , well after testing your code , the actual result is :1.2246063538223773e-16 which is almost but not equal to 0

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts