Skip to content

Instantly share code, notes, and snippets.

@kashmervil
Created September 19, 2014 10:59
Show Gist options
  • Save kashmervil/d8d070dcdcb54cf94f35 to your computer and use it in GitHub Desktop.
Save kashmervil/d8d070dcdcb54cf94f35 to your computer and use it in GitHub Desktop.
Неприятный баг в тестовой системе. Особенно заметный при использовании функций с generics-параметрами. Два файла: До загрузки и после
using System;
namespace Integral
{
class Program
{
static void Main(string[] args)
{
var result = Integral(((x, y) => 1.0), 0, Math.PI/2);
Console.WriteLine(result);
}
private static double Integral(Func, Tuple>>>, double, double> f, double a, double b)
{
const int n = 10000;
var h = (b - a)/n;
var result = 0.0;
for (var i = 0; i < n; i++)
{
result += f(new Object(), 1.0);
}
return result*h;
}
}
}
using System;
namespace Integral
{
class Program
{
static void Main(string[] args)
{
var result = Integral(((x, y) => 1.0), 0, Math.PI/2);
Console.WriteLine(result);
}
private static double Integral(Func<Tuple<int, Tuple<string, int, Func<Func<int, UInt16>, Tuple<object, object>>>>, double, double> f, double a, double b)
{
const int n = 10000;
var h = (b - a)/n;
var result = 0.0;
for (var i = 0; i < n; i++)
{
result += 0.1;
}
return result*h;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment