[System.Security.SecuritySafeCritical] // auto-generated internal static Decimal Round(Decimal d, int decimals, MidpointRounding mode) { if (decimals < 0 || decimals > 28) { throw new ArgumentOutOfRangeException("decimals", SR.ArgumentOutOfRange_DecimalRound); } if (mode < MidpointRounding.ToEven || mode > MidpointRounding.AwayFromZero) { throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, "MidpointRounding"), "mode"); } Contract.EndContractBlock(); if (mode == MidpointRounding.ToEven) { Decimal result = new Decimal(); if (DecCalc.VarDecRound(ref d, decimals, ref result) < 0) { throw new OverflowException(SR.Overflow_Decimal); } d = result; } else { DecCalc.InternalRoundFromZero(ref d, decimals); } return(d); }
public static Decimal Round(Decimal d, int decimals) { Decimal result = new Decimal(); if (decimals < 0 || decimals > 28) { throw new ArgumentOutOfRangeException(nameof(decimals), SR.ArgumentOutOfRange_DecimalRound); } DecCalc.VarDecRound(ref d, decimals, ref result); d = result; return(d); }
[System.Security.SecuritySafeCritical] // auto-generated internal static Decimal Round(Decimal d, int decimals) { Decimal result = new Decimal(); if (decimals < 0 || decimals > 28) { throw new ArgumentOutOfRangeException("decimals", SR.ArgumentOutOfRange_DecimalRound); } if (DecCalc.VarDecRound(ref d, decimals, ref result) < 0) { throw new OverflowException(SR.Overflow_Decimal); } d = result; return(d); }
public static Decimal Round(Decimal d, int decimals, MidpointRounding mode) { if (decimals < 0 || decimals > 28) { throw new ArgumentOutOfRangeException(nameof(decimals), SR.ArgumentOutOfRange_DecimalRound); } if (mode < MidpointRounding.ToEven || mode > MidpointRounding.AwayFromZero) { throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, "MidpointRounding"), nameof(mode)); } if (mode == MidpointRounding.ToEven) { Decimal result = new Decimal(); DecCalc.VarDecRound(ref d, decimals, ref result); d = result; } else { DecCalc.InternalRoundFromZero(ref d, decimals); } return(d); }