コード例 #1
0
ファイル: Decimal.cs プロジェクト: chcosta/corert
        private static void Truncate(ref Decimal d)
        {
            uint flags = d.uflags;

            if ((flags & ScaleMask) != 0)
            {
                DecCalc.InternalRound(ref d, (byte)(flags >> ScaleShift), DecCalc.RoundingMode.Truncate);
            }
        }
コード例 #2
0
ファイル: Decimal.cs プロジェクト: chcosta/corert
        // Rounds a Decimal to an integer value. The Decimal argument is rounded
        // towards negative infinity.
        //
        public static Decimal Floor(Decimal d)
        {
            uint flags = d.uflags;

            if ((flags & ScaleMask) != 0)
            {
                DecCalc.InternalRound(ref d, (byte)(flags >> ScaleShift), DecCalc.RoundingMode.Floor);
            }
            return(d);
        }
コード例 #3
0
ファイル: Decimal.cs プロジェクト: chcosta/corert
        private static Decimal Round(ref Decimal d, int decimals, MidpointRounding mode)
        {
            if ((uint)decimals > 28)
            {
                throw new ArgumentOutOfRangeException(nameof(decimals), SR.ArgumentOutOfRange_DecimalRound);
            }
            if ((uint)mode > (uint)MidpointRounding.AwayFromZero)
            {
                throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, nameof(MidpointRounding)), nameof(mode));
            }

            int scale = d.Scale - decimals;

            if (scale > 0)
            {
                DecCalc.InternalRound(ref d, (uint)scale, (DecCalc.RoundingMode)mode);
            }
            return(d);
        }