2008-09-28 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Sun, 28 Sep 2008 14:55:32 +0000 (14:55 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Sun, 28 Sep 2008 14:55:32 +0000 (14:55 -0000)
* Enumerable.cs: Add missing cast Average on IEnumerable<long?> to
ensure the result is not truncated.
[Found using Gendarme's ReviewCastOnIntegerDivisionRule]

svn path=/trunk/mcs/; revision=114330

mcs/class/System.Core/System.Linq/ChangeLog
mcs/class/System.Core/System.Linq/Enumerable.cs

index 0bbceee21720447e83f8bea33cb4bfbab590883c..c855640e0cdeccd0aba55f7c57b4a9a27174fc06 100644 (file)
@@ -1,3 +1,9 @@
+2008-09-28  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * Enumerable.cs: Add missing cast Average on IEnumerable<long?> to
+       ensure the result is not truncated.
+       [Found using Gendarme's ReviewCastOnIntegerDivisionRule]
+
 2008-09-11  Jb Evain  <jbevain@novell.com>
 
        * Enumerable.cs (Iterate*): use a bool empty instead of an int counter.
index 4d46b21bc0a431d5927645d9739417f6694e4e10..ac06748b64a2a3fe10a6800736478209ed684217 100644 (file)
@@ -225,7 +225,7 @@ namespace System.Linq
                {
                        Check.Source (source);
 
-                       return source.AverageNullable<long, long, double> ((a, b) => a + b, (a, b) => a / b);
+                       return source.AverageNullable<long, long, double> ((a, b) => a + b, (a, b) => (double) a / b);
                }
 
                public static double? Average (this IEnumerable<double?> source)