Moving GetExponent/Mantissa and make BigInteger used fixed-sized buffer
authorTanner Gooding <tagoo@outlook.com>
Wed, 19 Sep 2018 21:25:36 +0000 (14:25 -0700)
committerTanner Gooding <tagoo@outlook.com>
Thu, 20 Sep 2018 20:12:46 +0000 (13:12 -0700)
src/System.Private.CoreLib/shared/System/Double.cs
src/System.Private.CoreLib/shared/System/Number.BigInteger.cs
src/System.Private.CoreLib/shared/System/Number.Formatting.cs

index a4c0119..d85b4bc 100644 (file)
@@ -44,22 +44,6 @@ namespace System
         // We use this explicit definition to avoid the confusion between 0.0 and -0.0.
         internal const double NegativeZero = -0.0;
 
-        [NonVersionable]
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        internal static int GetExponent(double d)
-        {
-            var bits = BitConverter.DoubleToInt64Bits(d);
-            return (int)((bits >> 52) & 0x7FF);
-        }
-
-        [NonVersionable]
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        internal static long GetMantissa(double d)
-        {
-            var bits = BitConverter.DoubleToInt64Bits(d);
-            return (bits & 0xFFFFFFFFFFFFF);
-        }
-
         /// <summary>Determines whether the specified value is finite (zero, subnormal, or normal).</summary>
         [NonVersionable]
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
index 4d3e887..2629fe2 100644 (file)
@@ -721,9 +721,11 @@ namespace System
                 }
             }
 
-            [StructLayout(LayoutKind.Sequential, Size = (MaxBlockCount * sizeof(uint)))]
+            [StructLayout(LayoutKind.Sequential, Pack = 1)]
             private struct BlocksBuffer
             {
+                private fixed uint _blocks[MaxBlockCount];
+                
                 public ref uint this[int index]
                 {
                     get
index 1343686..e9c21a7 100644 (file)
@@ -2310,8 +2310,9 @@ SkipRounding:
 
         private static long ExtractFractionAndBiasedExponent(double value, out int exponent)
         {
-            long fraction = double.GetMantissa(value);
-            exponent = double.GetExponent(value);
+            var bits = BitConverter.DoubleToInt64Bits(value);
+            long fraction = (bits & 0xFFFFFFFFFFFFF);
+            exponent = (int)((bits >> 52) & 0x7FF);
 
             if (exponent != 0)
             {