Follow @RoyOsherove on Twitter

Funny Behaviour

Tamar, a friend of mine, alerted me to this funny behaviour.

can anyone tell me why the following code:

static void Main(string[] args)

{

Console.WriteLine(21 - 5.45);

Console.WriteLine(21 - 20.45);

Console.Read();

}

produces this:

15.55
0.550000000000001

This happens in C#,VB.NET and VB6.  What's going on here?

My Baby Hits The Road Tomorrow

Data Binding Woes - A Simple Solution