[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]
Loading

VulpesRank #55 · 29.2K reputationPosted Jul 20, 2012, 9:11 AM EDT
tom jones18 reputationPosted Jul 20, 2012, 9:38 AM EDT
Thanks.
VulpesRank #55 · 29.2K reputationPosted Jul 20, 2012, 9:56 AM EDT
So you might like to try that, if you haven't done so already.
VulpesRank #55 · 29.2K reputationPosted Jul 20, 2012, 10:49 AM EDT
Check out this thread and the post by Eric Lippert, who's a member of the C# compiler team, in particular: