148 references to MidpointRounding
Aspire.Dashboard (1)
Otlp\Model\DurationFormatter.cs (1)
43var secondaryValue = Math.Round((ticks / secondaryUnit.Ticks) % ofPrevious, MidpointRounding.AwayFromZero);
Microsoft.DotNet.XUnitAssert.Tests (2)
EqualityAssertsTests.cs (2)
799 Assert.Equal(10.566, 10.565, 2, MidpointRounding.AwayFromZero); 805 Assert.Equal(0.00, 0.05, 1, MidpointRounding.ToEven);
mscorlib (1)
src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
363[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.MidpointRounding))]
netstandard (1)
netstandard.cs (1)
1055[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.MidpointRounding))]
PresentationCore (3)
MS\Internal\TextFormatting\TextFormatterImp.cs (3)
643return RoundDipForDisplayMode(value, pixelsPerDip, MidpointRounding.ToEven); 646private static double RoundDipForDisplayMode(double value, double pixelsPerDip, MidpointRounding midpointRounding) 666return RoundDipForDisplayMode(value, pixelsPerDip, MidpointRounding.AwayFromZero);
System.Numerics.Tensors (35)
System\Numerics\Tensors\netcore\Tensor.cs (12)
4582public static Tensor<T> Round<T>(in ReadOnlyTensorSpan<T> x, int digits, MidpointRounding mode) 4586TensorOperation.Invoke<TensorOperation.Round<T>, T, Tuple<int, MidpointRounding>, T>(x, Tuple.Create(digits, mode), destination); 4595public static ref readonly TensorSpan<T> Round<T>(scoped in ReadOnlyTensorSpan<T> x, int digits, MidpointRounding mode, in TensorSpan<T> destination) 4599TensorOperation.Invoke<TensorOperation.Round<T>, T, Tuple<int, MidpointRounding>, T>(x, Tuple.Create(digits, mode), in destination); 4610TensorOperation.Invoke<TensorOperation.Round<T>, T, Tuple<int, MidpointRounding>, T>(x, Tuple.Create(digits, MidpointRounding.ToEven), destination); 4622TensorOperation.Invoke<TensorOperation.Round<T>, T, Tuple<int, MidpointRounding>, T>(x, Tuple.Create(digits, MidpointRounding.ToEven), in destination); 4629public static Tensor<T> Round<T>(in ReadOnlyTensorSpan<T> x, MidpointRounding mode) 4633TensorOperation.Invoke<TensorOperation.Round<T>, T, Tuple<int, MidpointRounding>, T>(x, Tuple.Create(0, mode), destination); 4641public static ref readonly TensorSpan<T> Round<T>(scoped in ReadOnlyTensorSpan<T> x, MidpointRounding mode, in TensorSpan<T> destination) 4645TensorOperation.Invoke<TensorOperation.Round<T>, T, Tuple<int, MidpointRounding>, T>(x, Tuple.Create(0, mode), in destination);
System\Numerics\Tensors\netcore\TensorOperation.cs (3)
1842IBinaryOperation_Tensor_Scalar<T, Tuple<int, MidpointRounding>, T> 1855public static void Invoke(ref readonly T x, Tuple<int, MidpointRounding> y, ref T destination) 1860public static void Invoke(ReadOnlySpan<T> x, Tuple<int, MidpointRounding> y, Span<T> destination)
System\Numerics\Tensors\netcore\TensorPrimitives.Round.cs (20)
44public static void Round<T>(ReadOnlySpan<T> x, MidpointRounding mode, Span<T> destination) 49case MidpointRounding.ToEven: 53case MidpointRounding.AwayFromZero: 62case MidpointRounding.ToZero: 66case MidpointRounding.ToNegativeInfinity: 70case MidpointRounding.ToPositiveInfinity: 75throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, typeof(MidpointRounding)), nameof(mode)); 91Round(x, digits, MidpointRounding.ToEven, destination); 107public static void Round<T>(ReadOnlySpan<T> x, int digits, MidpointRounding mode, Span<T> destination) 129if ((uint)mode > (uint)MidpointRounding.ToPositiveInfinity) 131throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, typeof(MidpointRounding)), nameof(mode)); 146case MidpointRounding.ToEven: 150case MidpointRounding.AwayFromZero: 154case MidpointRounding.ToZero: 158case MidpointRounding.ToNegativeInfinity: 162case MidpointRounding.ToPositiveInfinity: 167throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, typeof(MidpointRounding)), nameof(mode)); 252public static T Invoke(T x) => T.Round(x, MidpointRounding.AwayFromZero); 356private readonly struct RoundFallbackOperator<T>(int digits, MidpointRounding mode) : IStatefulUnaryOperator<T> 360private readonly MidpointRounding _mode = mode;
System.Private.CoreLib (98)
src\libraries\System.Private.CoreLib\src\System\Decimal.cs (10)
401DecCalc.InternalRound(ref AsMutable(ref d), (byte)(flags >> ScaleShift), MidpointRounding.ToPositiveInfinity); 473DecCalc.InternalRound(ref AsMutable(ref d), (byte)(flags >> ScaleShift), MidpointRounding.ToNegativeInfinity); 679public static decimal Round(decimal d) => Round(ref d, 0, MidpointRounding.ToEven); 680public static decimal Round(decimal d, int decimals) => Round(ref d, decimals, MidpointRounding.ToEven); 681public static decimal Round(decimal d, MidpointRounding mode) => Round(ref d, 0, mode); 682public static decimal Round(decimal d, int decimals, MidpointRounding mode) => Round(ref d, decimals, mode); 684private static decimal Round(ref decimal d, int decimals, MidpointRounding mode) 688if ((uint)mode > (uint)MidpointRounding.ToPositiveInfinity) 689throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, nameof(MidpointRounding)), nameof(mode)); 898DecCalc.InternalRound(ref AsMutable(ref d), (byte)(flags >> ScaleShift), MidpointRounding.ToZero);
src\libraries\System.Private.CoreLib\src\System\Decimal.DecCalc.cs (8)
1296InternalRound(ref pdecIn, (uint)scale, MidpointRounding.ToEven); 2388internal static void InternalRound(ref DecCalc d, uint scale, MidpointRounding mode) 2440if (mode <= MidpointRounding.ToZero) 2469if (mode == MidpointRounding.ToZero) 2471else if (mode == MidpointRounding.ToEven) 2480else if (mode == MidpointRounding.AwayFromZero) 2487else if (mode == MidpointRounding.ToNegativeInfinity) 2495Debug.Assert(mode == MidpointRounding.ToPositiveInfinity);
src\libraries\System.Private.CoreLib\src\System\Double.cs (4)
688/// <inheritdoc cref="IFloatingPoint{TSelf}.Round(TSelf, MidpointRounding)" /> 689public static double Round(double x, MidpointRounding mode) => Math.Round(x, mode); 691/// <inheritdoc cref="IFloatingPoint{TSelf}.Round(TSelf, int, MidpointRounding)" /> 692public static double Round(double x, int digits, MidpointRounding mode) => Math.Round(x, digits, mode);
src\libraries\System.Private.CoreLib\src\System\Half.cs (4)
1332/// <inheritdoc cref="IFloatingPoint{TSelf}.Round(TSelf, MidpointRounding)" /> 1333public static Half Round(Half x, MidpointRounding mode) => (Half)MathF.Round((float)x, mode); 1335/// <inheritdoc cref="IFloatingPoint{TSelf}.Round(TSelf, int, MidpointRounding)" /> 1336public static Half Round(Half x, int digits, MidpointRounding mode) => (Half)MathF.Round((float)x, digits, mode);
src\libraries\System.Private.CoreLib\src\System\Math.cs (10)
1296public static decimal Round(decimal d, MidpointRounding mode) 1302public static decimal Round(decimal d, int decimals, MidpointRounding mode) 1354return Round(value, digits, MidpointRounding.ToEven); 1358public static double Round(double value, MidpointRounding mode) 1364case MidpointRounding.AwayFromZero: 1374case MidpointRounding.ToEven: 1377case MidpointRounding.ToZero: 1380case MidpointRounding.ToNegativeInfinity: 1383case MidpointRounding.ToPositiveInfinity: 1393public static double Round(double value, int digits, MidpointRounding mode)
src\libraries\System.Private.CoreLib\src\System\MathF.cs (8)
391return Round(x, digits, MidpointRounding.ToEven); 395public static float Round(float x, MidpointRounding mode) 401case MidpointRounding.AwayFromZero: 411case MidpointRounding.ToEven: 414case MidpointRounding.ToZero: 417case MidpointRounding.ToNegativeInfinity: 420case MidpointRounding.ToPositiveInfinity: 430public static float Round(float x, int digits, MidpointRounding mode)
src\libraries\System.Private.CoreLib\src\System\Numerics\IFloatingPoint.cs (9)
17static virtual TSelf Ceiling(TSelf x) => TSelf.Round(x, digits: 0, MidpointRounding.ToPositiveInfinity); 42static virtual TSelf Floor(TSelf x) => TSelf.Round(x, digits: 0, MidpointRounding.ToNegativeInfinity); 44/// <summary>Rounds a value to the nearest integer using the default rounding mode (<see cref="MidpointRounding.ToEven" />).</summary> 47static virtual TSelf Round(TSelf x) => TSelf.Round(x, digits: 0, MidpointRounding.ToEven); 49/// <summary>Rounds a value to a specified number of fractional-digits using the default rounding mode (<see cref="MidpointRounding.ToEven" />).</summary> 53static virtual TSelf Round(TSelf x, int digits) => TSelf.Round(x, digits, MidpointRounding.ToEven); 59static virtual TSelf Round(TSelf x, MidpointRounding mode) => TSelf.Round(x, digits: 0, mode); 66static abstract TSelf Round(TSelf x, int digits, MidpointRounding mode); 71static virtual TSelf Truncate(TSelf x) => TSelf.Round(x, digits: 0, MidpointRounding.ToZero);
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector.cs (4)
2648/// <inheritdoc cref="Vector128.Round(Vector128{double}, MidpointRounding)" /> 2650public static Vector<double> Round(Vector<double> vector, MidpointRounding mode) => VectorMath.RoundDouble(vector, mode); 2652/// <inheritdoc cref="Vector128.Round(Vector128{float}, MidpointRounding)" /> 2654public static Vector<float> Round(Vector<float> vector, MidpointRounding mode) => VectorMath.RoundSingle(vector, mode);
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector2.cs (2)
852/// <inheritdoc cref="Vector4.Round(Vector4, MidpointRounding)" /> 854public static Vector2 Round(Vector2 vector, MidpointRounding mode) => Vector128.Round(vector.AsVector128Unsafe(), mode).AsVector2();
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector3.cs (2)
882/// <inheritdoc cref="Vector4.Round(Vector4, MidpointRounding)" /> 884public static Vector3 Round(Vector3 vector, MidpointRounding mode) => Vector128.Round(vector.AsVector128Unsafe(), mode).AsVector3();
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector4.cs (2)
917/// <inheritdoc cref="Vector128.Round(Vector128{float}, MidpointRounding)" /> 919public static Vector4 Round(Vector4 vector, MidpointRounding mode) => Vector128.Round(vector.AsVector128(), mode).AsVector4();
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\NFloat.cs (4)
1000/// <inheritdoc cref="IFloatingPoint{TSelf}.Round(TSelf, MidpointRounding)" /> 1001public static NFloat Round(NFloat x, MidpointRounding mode) => new NFloat(NativeType.Round(x._value, mode)); 1003/// <inheritdoc cref="IFloatingPoint{TSelf}.Round(TSelf, int, MidpointRounding)" /> 1004public static NFloat Round(NFloat x, int digits, MidpointRounding mode) => new NFloat(NativeType.Round(x._value, digits, mode));
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\ISimdVector_2.cs (1)
688/// <summary>Rounds each element in a vector to the nearest integer using the default rounding mode (<see cref="MidpointRounding.ToEven" />).</summary>
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector128.cs (4)
2997/// <inheritdoc cref="Vector64.Round(Vector64{double}, MidpointRounding)" /> 2999public static Vector128<double> Round(Vector128<double> vector, MidpointRounding mode) => VectorMath.RoundDouble(vector, mode); 3001/// <inheritdoc cref="Vector64.Round(Vector64{float}, MidpointRounding)" /> 3003public static Vector128<float> Round(Vector128<float> vector, MidpointRounding mode) => VectorMath.RoundSingle(vector, mode);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector256.cs (4)
3032/// <inheritdoc cref="Vector128.Round(Vector128{double}, MidpointRounding)" /> 3034public static Vector256<double> Round(Vector256<double> vector, MidpointRounding mode) => VectorMath.RoundDouble(vector, mode); 3036/// <inheritdoc cref="Vector128.Round(Vector128{float}, MidpointRounding)" /> 3038public static Vector256<float> Round(Vector256<float> vector, MidpointRounding mode) => VectorMath.RoundSingle(vector, mode);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector512.cs (4)
3057/// <inheritdoc cref="Vector256.Round(Vector256{double}, MidpointRounding)" /> 3059public static Vector512<double> Round(Vector512<double> vector, MidpointRounding mode) => VectorMath.RoundDouble(vector, mode); 3061/// <inheritdoc cref="Vector256.Round(Vector256{float}, MidpointRounding)" /> 3063public static Vector512<float> Round(Vector512<float> vector, MidpointRounding mode) => VectorMath.RoundSingle(vector, mode);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector64.cs (2)
3056public static Vector64<double> Round(Vector64<double> vector, MidpointRounding mode) => VectorMath.RoundDouble(vector, mode); 3063public static Vector64<float> Round(Vector64<float> vector, MidpointRounding mode) => VectorMath.RoundSingle(vector, mode);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\VectorMath.cs (12)
1694public static TVectorDouble RoundDouble<TVectorDouble>(TVectorDouble vector, MidpointRounding mode) 1701case MidpointRounding.AwayFromZero: 1709case MidpointRounding.ToEven: 1715case MidpointRounding.ToZero: 1721case MidpointRounding.ToNegativeInfinity: 1727case MidpointRounding.ToPositiveInfinity: 1740public static TVectorSingle RoundSingle<TVectorSingle>(TVectorSingle vector, MidpointRounding mode) 1747case MidpointRounding.AwayFromZero: 1755case MidpointRounding.ToEven: 1761case MidpointRounding.ToZero: 1767case MidpointRounding.ToNegativeInfinity: 1773case MidpointRounding.ToPositiveInfinity:
src\libraries\System.Private.CoreLib\src\System\Single.cs (4)
683/// <inheritdoc cref="IFloatingPoint{TSelf}.Round(TSelf, MidpointRounding)" /> 684public static float Round(float x, MidpointRounding mode) => MathF.Round(x, mode); 686/// <inheritdoc cref="IFloatingPoint{TSelf}.Round(TSelf, int, MidpointRounding)" /> 687public static float Round(float x, int digits, MidpointRounding mode) => MathF.Round(x, digits, mode);
System.Runtime (1)
artifacts\obj\System.Runtime\Debug\net10.0\System.Runtime.Forwards.cs (1)
352[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.MidpointRounding))]
System.Runtime.Extensions (1)
System.Runtime.Extensions.cs (1)
51[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.MidpointRounding))]
System.Windows.Forms (3)
System\Windows\Forms\Controls\DataGridView\DataGridView.Methods.cs (3)
1003dataGridViewColumn.DesiredFillWidth = (int)Math.Round(desiredFillWidth, MidpointRounding.AwayFromZero); 1158mostDeservingDataGridViewColumn.DesiredFillWidth = Math.Min(oldDesiredWidth, (int)Math.Round(floatDesiredWidth, MidpointRounding.AwayFromZero)); 1230mostDeservingDataGridViewColumn.DesiredFillWidth = Math.Max(mostDeservingDataGridViewColumn.MinimumWidth, (int)Math.Round(floatDesiredWidth, MidpointRounding.AwayFromZero));
xunit.assert (2)
EqualityAsserts.cs (2)
146 MidpointRounding rounding) 203 MidpointRounding rounding) =>