158 references to MidpointRounding
Aspire.Dashboard (1)
Otlp\Model\DurationFormatter.cs (1)
42var secondaryValue = Math.Round((ticks / secondaryUnit.Ticks) % ofPrevious, MidpointRounding.AwayFromZero);
Microsoft.Build (2)
Evaluation\Profiler\EvaluationLocationPrettyPrinterBase.cs (2)
36return Math.Round(timeSpan.TotalMilliseconds, 0, MidpointRounding.AwayFromZero); 44return Math.Round(percentage, 1, MidpointRounding.AwayFromZero);
Microsoft.DotNet.XUnitAssert.Tests (8)
EqualityAssertsTests.cs (8)
2034 Assert.Equal(10.565, 10.566, 2, MidpointRounding.AwayFromZero); 2044 var ex = Record.Exception(() => Assert.Equal(0.11113, 0.11115, 4, MidpointRounding.ToEven)); 2194 Assert.Equal(10.5655f, 10.5666f, 2, MidpointRounding.AwayFromZero); 2204 var ex = Record.Exception(() => Assert.Equal(0.111133f, 0.111155f, 4, MidpointRounding.ToEven)); 4012 var ex = Record.Exception(() => Assert.NotEqual(10.565, 10.566, 2, MidpointRounding.AwayFromZero)); 4026 Assert.NotEqual(0.11113, 0.11115, 4, MidpointRounding.ToEven); 4160 var ex = Record.Exception(() => Assert.NotEqual(10.5655f, 10.5666f, 2, MidpointRounding.AwayFromZero)); 4174 Assert.NotEqual(0.111133f, 0.111155f, 4, 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)
5083public static Tensor<T> Round<T>(in ReadOnlyTensorSpan<T> x, int digits, MidpointRounding mode) 5087TensorOperation.Invoke<TensorOperation.Round<T>, T, Tuple<int, MidpointRounding>, T>(x, Tuple.Create(digits, mode), destination); 5096public static ref readonly TensorSpan<T> Round<T>(scoped in ReadOnlyTensorSpan<T> x, int digits, MidpointRounding mode, in TensorSpan<T> destination) 5100TensorOperation.Invoke<TensorOperation.Round<T>, T, Tuple<int, MidpointRounding>, T>(x, Tuple.Create(digits, mode), in destination); 5111TensorOperation.Invoke<TensorOperation.Round<T>, T, Tuple<int, MidpointRounding>, T>(x, Tuple.Create(digits, MidpointRounding.ToEven), destination); 5123TensorOperation.Invoke<TensorOperation.Round<T>, T, Tuple<int, MidpointRounding>, T>(x, Tuple.Create(digits, MidpointRounding.ToEven), in destination); 5130public static Tensor<T> Round<T>(in ReadOnlyTensorSpan<T> x, MidpointRounding mode) 5134TensorOperation.Invoke<TensorOperation.Round<T>, T, Tuple<int, MidpointRounding>, T>(x, Tuple.Create(0, mode), destination); 5142public static ref readonly TensorSpan<T> Round<T>(scoped in ReadOnlyTensorSpan<T> x, MidpointRounding mode, in TensorSpan<T> destination) 5146TensorOperation.Invoke<TensorOperation.Round<T>, T, Tuple<int, MidpointRounding>, T>(x, Tuple.Create(0, mode), in destination);
System\Numerics\Tensors\netcore\TensorOperation.cs (3)
1810IBinaryOperation_Tensor_Scalar<T, Tuple<int, MidpointRounding>, T> 1823public static void Invoke(ref readonly T x, Tuple<int, MidpointRounding> y, ref T destination) 1828public static void Invoke(ReadOnlySpan<T> x, Tuple<int, MidpointRounding> y, Span<T> destination)
System\Numerics\Tensors\netcore\TensorPrimitives.Round.cs (20)
39public static void Round<T>(ReadOnlySpan<T> x, MidpointRounding mode, Span<T> destination) 44case MidpointRounding.ToEven: 48case MidpointRounding.AwayFromZero: 52case MidpointRounding.ToZero: 56case MidpointRounding.ToNegativeInfinity: 60case MidpointRounding.ToPositiveInfinity: 65throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, typeof(MidpointRounding)), nameof(mode)); 81Round(x, digits, MidpointRounding.ToEven, destination); 97public static void Round<T>(ReadOnlySpan<T> x, int digits, MidpointRounding mode, Span<T> destination) 119if ((uint)mode > (uint)MidpointRounding.ToPositiveInfinity) 121throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, typeof(MidpointRounding)), nameof(mode)); 136case MidpointRounding.ToEven: 140case MidpointRounding.AwayFromZero: 144case MidpointRounding.ToZero: 148case MidpointRounding.ToNegativeInfinity: 152case MidpointRounding.ToPositiveInfinity: 157throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, typeof(MidpointRounding)), nameof(mode)); 242public static T Invoke(T x) => T.Round(x, MidpointRounding.AwayFromZero); 346private readonly struct RoundFallbackOperator<T>(int digits, MidpointRounding mode) : IStatefulUnaryOperator<T> 350private 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); 678public static decimal Round(decimal d) => Round(ref d, 0, MidpointRounding.ToEven); 679public static decimal Round(decimal d, int decimals) => Round(ref d, decimals, MidpointRounding.ToEven); 680public static decimal Round(decimal d, MidpointRounding mode) => Round(ref d, 0, mode); 681public static decimal Round(decimal d, int decimals, MidpointRounding mode) => Round(ref d, decimals, mode); 683private static decimal Round(ref decimal d, int decimals, MidpointRounding mode) 687if ((uint)mode > (uint)MidpointRounding.ToPositiveInfinity) 688throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, nameof(MidpointRounding)), nameof(mode)); 897DecCalc.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)
1306public static decimal Round(decimal d, MidpointRounding mode) 1312public static decimal Round(decimal d, int decimals, MidpointRounding mode) 1364return Round(value, digits, MidpointRounding.ToEven); 1368public static double Round(double value, MidpointRounding mode) 1374case MidpointRounding.AwayFromZero: 1384case MidpointRounding.ToEven: 1387case MidpointRounding.ToZero: 1390case MidpointRounding.ToNegativeInfinity: 1393case MidpointRounding.ToPositiveInfinity: 1403public 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)
2597/// <inheritdoc cref="Vector128.Round(Vector128{double}, MidpointRounding)" /> 2599public static Vector<double> Round(Vector<double> vector, MidpointRounding mode) => VectorMath.RoundDouble(vector, mode); 2601/// <inheritdoc cref="Vector128.Round(Vector128{float}, MidpointRounding)" /> 2603public 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)
885/// <inheritdoc cref="Vector4.Round(Vector4, MidpointRounding)" /> 887public 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)
2806/// <inheritdoc cref="Vector64.Round(Vector64{double}, MidpointRounding)" /> 2808public static Vector128<double> Round(Vector128<double> vector, MidpointRounding mode) => VectorMath.RoundDouble(vector, mode); 2810/// <inheritdoc cref="Vector64.Round(Vector64{float}, MidpointRounding)" /> 2812public 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)
2910/// <inheritdoc cref="Vector128.Round(Vector128{double}, MidpointRounding)" /> 2912public static Vector256<double> Round(Vector256<double> vector, MidpointRounding mode) => VectorMath.RoundDouble(vector, mode); 2914/// <inheritdoc cref="Vector128.Round(Vector128{float}, MidpointRounding)" /> 2916public 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)
2936/// <inheritdoc cref="Vector256.Round(Vector256{double}, MidpointRounding)" /> 2938public static Vector512<double> Round(Vector512<double> vector, MidpointRounding mode) => VectorMath.RoundDouble(vector, mode); 2940/// <inheritdoc cref="Vector256.Round(Vector256{float}, MidpointRounding)" /> 2942public 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)
3008public static Vector64<double> Round(Vector64<double> vector, MidpointRounding mode) => VectorMath.RoundDouble(vector, mode); 3015public 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)
1693public static TVectorDouble RoundDouble<TVectorDouble>(TVectorDouble vector, MidpointRounding mode) 1700case MidpointRounding.AwayFromZero: 1708case MidpointRounding.ToEven: 1714case MidpointRounding.ToZero: 1720case MidpointRounding.ToNegativeInfinity: 1726case MidpointRounding.ToPositiveInfinity: 1739public static TVectorSingle RoundSingle<TVectorSingle>(TVectorSingle vector, MidpointRounding mode) 1746case MidpointRounding.AwayFromZero: 1754case MidpointRounding.ToEven: 1760case MidpointRounding.ToZero: 1766case MidpointRounding.ToNegativeInfinity: 1772case 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)
351[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 (4)
EqualityAsserts.cs (4)
370 MidpointRounding rounding) 442 MidpointRounding rounding) 851 MidpointRounding rounding) 923 MidpointRounding rounding)