I've encountered a rather bizarre VS.NET 2003 behaviour.

See code comments below:

using System;

namespace DoubleTest
{
 class Class1
 {
  [STAThread]
  static void Main(string[] args)
  {
   // When debuggin this code, val variable value in
watch window is 1.1300000000000001 !?!!?!??!
   // yet console output shows correct value = 1.13
   // What the?
   double val = 1.1D + 0.01D * 3.0D;
   Console.WriteLine(val.ToString());

   // same thing here, the displayed value for val2
in debug watch window is 2.2600000000000002
   // but console output is correct 2.26
   double val2 = val * 2D;
   Console.WriteLine(val2.ToString());
  }
 }
}

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to