Meine Kopie von VS2013 Ultimative diesen Code für 60+ Sekunden kompiliert:Visual Studio und MSSE Anti-Virus-Kompilierung Fehler
class Program
{
static void Main(string[] args)
{
double dichotomy = Dichotomy(
d =>
{
try
{
int size = (int) d;
byte[] b = new byte[size];
return -b.Length;
}
catch (Exception)
{
return 0;
}
},
0,
int.MaxValue,
1);
Console.WriteLine(dichotomy);
Console.ReadKey();
}
private static double Dichotomy(
Func<double, double> func,
double a,
double b,
double epsilon)
{
double delta = epsilon/10;
while (b - a >= epsilon)
{
double middle = (a + b)/2;
double lambda = middle - delta, mu = middle + delta;
if (func(lambda) < func(mu))
b = mu;
else
a = lambda;
}
return (a + b)/2;
}
}
Aber wenn ich double
mit int
ersetzen, es kompiliert sofort. Wie kann es erklärt werden ...?
Kompiliert sofort auf meiner Maschine, für beide Datentypen ... Auf welcher Maschine kompilieren Sie es? –
Scratch meinen ersten Kommentar; Ich sehe das gleiche Verhalten. ~ 15 Sekunden mit 'double' und instant mit' int'. 3.4Ghz Maschine. –
Interessant. Ich überprüfte meine Version und ich lief tatsächlich VS2013 Premium - dachte ich hätte Ultimate installiert. Vielleicht ist es nur die Ultimate-Version, mit der dies geschieht. –