From 1d60b98ebad73eb0b2944e98a3f8bd09b893eeb0 Mon Sep 17 00:00:00 2001 From: Jeff Hardy Date: Thu, 1 Aug 2013 21:55:10 -0700 Subject: [PATCH] Fix CP#27840 - sys.float_info differ from CPython. Since double.Min and double.Epsilon are different from DBL_MIN and DBL_EPSILON, hardcode the values of the C constants instead. --- .../IronPython/IronPython/Modules/sys.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Languages/IronPython/IronPython/Modules/sys.cs b/Languages/IronPython/IronPython/Modules/sys.cs index 6a11f27c23..f860aea42f 100644 --- a/Languages/IronPython/IronPython/Modules/sys.cs +++ b/Languages/IronPython/IronPython/Modules/sys.cs @@ -747,7 +747,20 @@ public override string __repr__(CodeContext context) { } } - public static floatinfo float_info = new floatinfo(Double.MaxValue, 1024, 308, Double.MinValue, -1021, -307, 15, 53, Double.Epsilon, 2, 1); + public static floatinfo float_info = new floatinfo( + Double.MaxValue, // DBL_MAX + 1024, // DBL_MAX_EXP + 308, // DBL_MAX_10_EXP + // DBL_MIN + BitConverter.Int64BitsToDouble(BitConverter.IsLittleEndian ? 0x0010000000000000 : 0x0000000000001000), + -1021, // DBL_MIN_EXP + -307, // DBL_MIN_10_EXP + 15, // DBL_DIG + 53, // DBL_MANT_DIG + // DBL_EPSILON + BitConverter.Int64BitsToDouble(BitConverter.IsLittleEndian ? 0x3cb0000000000000 : 0x000000000000b03c), + 2, // FLT_RADIX + 1); // FLT_ROUNDS [PythonType("sys.float_info"), PythonHidden] public class floatinfo : PythonTuple { @@ -788,8 +801,8 @@ internal floatinfo(double max, int max_exp, int max_10_exp, public const int n_unnamed_fields = 0; public override string __repr__(CodeContext context) { - return string.Format("sys.float_info(max={0}, max_exp={1}, max_10_exp={2}," + - "min={3}, min_exp={4}, min_10_exp={5}," + + return string.Format("sys.float_info(max={0}, max_exp={1}, max_10_exp={2}, " + + "min={3}, min_exp={4}, min_10_exp={5}, " + "dig={6}, mant_dig={7}, epsilon={8}, radix={9}, rounds={10})", max, max_exp, max_10_exp, min, min_exp, min_10_exp,