[Mono-list] Bug in mono floating point computation

Stephane SOPPERA stephane.soppera@free.fr
01 Dec 2002 20:10:57 +0100


Hi,

I think I saw a bug and I managed to isolate it in the following code:

using System;

class Bug{
	static void Main()
	{
		ulong u = 3960077;
		ulong f = 1000000;

		for (int i = 0; i< 10000000; ++i) 
		{
			Math.Cos(i);
	        }

		double d = u/(double)f;

		Console.WriteLine(d);
		
		d = u/(double)f;

		Console.WriteLine(d);


		
	}
}


this code produces the following output:
nan
3,960077

Is that a bug?
What I think to be the problem is that the nan comes from the cos
computation and since I'm not reading the output of cos a "nan flag"
keeps activated and is desactivated at the first floating point
computation following the cos.

I'm using mono 0.16 provided by the RPM for mandrake 8.2. I'm running a
mandrake 9.0.

Is that a bug?
Is it already corrected (I didn't see it in bugzilla)?

Thanks in advance,


-- 
Stephane SOPPERA
http://stephane.soppera.free.fr