X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fsysmath.c;h=386092de3c016611f8534021fa20adc389164671;hb=d421ee95b03dd2ffee3dcea9ef24406a5d064684;hp=45dc2ea04c4eec15ff861fa03b9e3e11777fbd62;hpb=0c56887d08d2f4a31145f116c21fb01fce246c51;p=mono.git diff --git a/mono/metadata/sysmath.c b/mono/metadata/sysmath.c index 45dc2ea04c4..386092de3c0 100644 --- a/mono/metadata/sysmath.c +++ b/mono/metadata/sysmath.c @@ -1,5 +1,6 @@ -/* - * sysmath.c: these are based on bob smith's csharp routines +/** + * \file + * these are based on bob smith's csharp routines * * Author: * Mono Project (http://www.mono-project.com) @@ -8,6 +9,7 @@ * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com) * Copyright 2004-2009 Novell, Inc (http://www.novell.com) * Copyright 2015 Xamarin, Inc (https://www.xamarin.com) + * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ // @@ -264,9 +266,19 @@ ves_icall_System_Math_Pow (gdouble x, gdouble y) result = PInfinity.d; #if defined (__linux__) && SIZEOF_VOID_P == 4 - /* On Linux 32bits, Math.Pow (-1, Double.MaxValue) would return NaN instead of 1 */ - if (isnan (result) && isminusone (x) && (y > 9007199254740991.0 || y < -9007199254740991.0)) - result = POne.d; + /* On Linux 32bits, some tests erroneously return NaN */ + if (isnan (result)) { + if (isminusone (x) && (y > 9007199254740991.0 || y < -9007199254740991.0)) { + /* Math.Pow (-1, Double.MaxValue) and Math.Pow (-1, Double.MinValue) should return 1 */ + result = POne.d; + } else if (x < -9007199254740991.0 && y < -9007199254740991.0) { + /* Math.Pow (Double.MinValue, Double.MinValue) should return 0 */ + result = 0.0; + } else if (x < -9007199254740991.0 && y > 9007199254740991.0) { + /* Math.Pow (Double.MinValue, Double.MaxValue) should return Double.PositiveInfinity */ + result = PInfinity.d; + } + } #endif return result == -0.0 ? 0 : result;