Problem with Math.Tan Function
[code]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Testing_Binary
{
class Program
{
static void Main(string[] args)
{
Double Radian = (Math.PI / 180);
Double count = 0;
int[] array = {1,0};
for (int i = 0; i < 2; i++)
{
if (array[i] == 1) count += Math.Tan(Radian);//POSITIVE COUNT = 0.0174550649282176
if (array[i] == 0) count += Math.Tan(-Radian);//NEGATIVE COUNT = -0.0174550649282176
}
//EXPECTING POSITVE AND NEGATIVE TO CANCELL EACH OTHER AND COUNT = 0, BUT GOT THE FOLLOWING:
Console.WriteLine("count = {0}", count);//I DON'T UNDERSTAND WHY = -4.06575814682064E-20
//I REALLY NEED TO UNDERSTAND WHAT HAPPEN. CAN SOMEONE PLEASE EXPLAIN?
}
}
}
[/code]