Example #1
0
            /// reconstructs a decimal value out of a signed integral component and a negative base-10 exponent
            private static decimal ReconstructFromNegativeScale(decimal mantissa, byte scale)
            {
                Span <int> buf = stackalloc int[4];

                CborHelpers.GetBitsFromDecimal(mantissa, buf);

                int  flags      = buf[3];
                bool isNegative = (flags & SignMask) == SignMask;

                Debug.Assert((flags & ScaleMask) == 0, "mantissa argument should be integral.");
                return(new decimal(lo: buf[0], mid: buf[1], hi: buf[2], isNegative: isNegative, scale: scale));
            }
Example #2
0
            /// deconstructs a decimal value into its signed integral component and negative base-10 exponent
            public static void Deconstruct(decimal value, out decimal mantissa, out byte scale)
            {
                Span <int> buf = stackalloc int[4];

                CborHelpers.GetBitsFromDecimal(value, buf);

                int  flags      = buf[3];
                bool isNegative = (flags & SignMask) == SignMask;

                mantissa = new decimal(lo: buf[0], mid: buf[1], hi: buf[2], isNegative: isNegative, scale: 0);
                scale    = (byte)((flags & ScaleMask) >> ScaleShift);
            }