[Mono-dev] Double multiplication
Vladimir Dimitrov
vlad.dimitrov at gmail.com
Thu Nov 29 08:02:17 EST 2007
Today was one of the strangest days that I had recently. I woke up today to
discover another way of thinking about numbers ::-)
To cut the long story short let me ask a simple question. Do you know the
result that the following code will produce as a console output:
using System;
namespace MultTest
{
class Program
{
static void Main (string [] args)
{
double d1 = 127.2;
double d2 = 128.2;
double hundred = 100;
Console.WriteLine ("{0} * {1} = {2}", d1, hundred, Math.Floor
(d1 * 100));
Console.WriteLine ("{0} * {1} = {2}", d2, hundred, Math.Floor
(d2 * 100));
Console.ReadKey ();
}
}
}
Well what I get from it is:
127.2 * 100 = 12720
128.2 * 100 = 12819
Am I the only one that thinks this is wrong? The things are even worse
because I noticed the problem on MS.NET first, and then on Mono and since
Microsoft is very unlikely to care about what I have to say, I decided that
you guys can be a lot more helpful.
Thanks
Vladimir Dimitrov
P.S. I tried it on different machines Core 2 Duo (T7200) and Pentium 4.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071129/c62e9c2e/attachment.html
More information about the Mono-devel-list
mailing list