< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 36
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
GetScale(...)100%110%
GetBits(...)100%110%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/DecimalUtilities.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4namespace System.Reflection.Internal
 5{
 6    internal static class DecimalUtilities
 7    {
 8        public static int GetScale(this decimal value)
 09        {
 010            Span<int> bits = [0, 0, 0, 0];
 011            decimal.GetBits(value, bits);
 012            return unchecked((byte)(bits[3] >> 16));
 013        }
 14
 15        public static void GetBits(this decimal value, out bool isNegative, out byte scale, out uint low, out uint mid, 
 016        {
 017            Span<int> bits = [0, 0, 0, 0];
 018            decimal.GetBits(value, bits);
 19
 20            // 'bits' is a four-element buffer of 32-bit signed integers.
 21            // The first, second, and third elements contain the low, middle, and high 32 bits of the 96-bit integer num
 022            low = unchecked((uint)bits[0]);
 023            mid = unchecked((uint)bits[1]);
 024            high = unchecked((uint)bits[2]);
 25
 26            // The fourth element of the returned array contains the scale factor and sign. It consists of the following
 27            // Bits 0 to 15, the lower word, are unused and must be zero.
 28            // Bits 16 to 23 must contain an exponent between 0 and 28, which indicates the power of 10 to divide the in
 29            // Bits 24 to 30 are unused and must be zero.
 30            // Bit 31 contains the sign; 0 meaning positive, and 1 meaning negative.
 031            scale = unchecked((byte)(bits[3] >> 16));
 032            isNegative = (bits[3] & 0x80000000) != 0;
 033        }
 34    }
 35}
 36