diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2022-09-09 07:13:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-09 07:13:35 +0300 |
commit | acf0dd20784a102670e459f1a869c1b4a34a388f (patch) | |
tree | 28f2a03321a9e5e17eca7cdf9f083cdd24a02db1 /src | |
parent | a141484a7bc24725bd19d770cfcf0f3538c9bb9b (diff) |
[release/7.0] Fix `Exp10M1(TSelf)` and `Round(TSelf, MidpointRounding)` (#75284)
* Don't ignore mode in IFloatingPoint.Round(TSelf, MipointRounding) DIM
* Fix recursion in IExponentialFunctions.Exp10M1's DIM
* Add tests for IExponentialFunctions.Exp10M1's DIM
* Add tests for IFloatingPoint.Round's DIM
* fix nits from tannergooding
Co-authored-by: Blokyk <32983140+Blokyk@users.noreply.github.com>
Co-authored-by: Blokyk <eliot.courvoisier@gmail.com>
Diffstat (limited to 'src')
6 files changed, 238 insertions, 2 deletions
diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IExponentialFunctions.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IExponentialFunctions.cs index f7370ff4708..b060924c8ce 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IExponentialFunctions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IExponentialFunctions.cs @@ -37,6 +37,6 @@ namespace System.Numerics /// <summary>Computes <c>10</c> raised to a given power and subtracts one.</summary> /// <param name="x">The power to which <c>10</c> is raised.</param> /// <returns><c>10<sup><paramref name="x" /></sup> - 1</c></returns> - static virtual TSelf Exp10M1(TSelf x) => TSelf.Exp10M1(x) - TSelf.One; + static virtual TSelf Exp10M1(TSelf x) => TSelf.Exp10(x) - TSelf.One; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPoint.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPoint.cs index 0abcc40ebbb..c8e58d8f8fb 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPoint.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPoint.cs @@ -36,7 +36,7 @@ namespace System.Numerics /// <param name="x">The value to round.</param> /// <param name="mode">The mode under which <paramref name="x" /> should be rounded.</param> /// <returns>The result of rounding <paramref name="x" /> to the nearest integer using <paramref name="mode" />.</returns> - static virtual TSelf Round(TSelf x, MidpointRounding mode) => TSelf.Round(x, digits: 0, MidpointRounding.ToEven); + static virtual TSelf Round(TSelf x, MidpointRounding mode) => TSelf.Round(x, digits: 0, mode); /// <summary>Rounds a value to a specified number of fractional-digits using the default rounding mode (<see cref="MidpointRounding.ToEven" />).</summary> /// <param name="x">The value to round.</param> diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj b/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj index accc11d4277..fc6859854dc 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj @@ -111,6 +111,8 @@ <Compile Include="System\NullableMetadataTests.cs" /> <Compile Include="System\NullableTests.cs" /> <Compile Include="System\NullReferenceExceptionTests.cs" /> + <Compile Include="System\Numerics\IExponentialFunctionsTests.cs" /> + <Compile Include="System\Numerics\IFloatingPointTests.cs" /> <Compile Include="System\ObjectTests.cs" /> <Compile Include="System\ObjectDisposedExceptionTests.cs" /> <Compile Include="System\ObsoleteAttributeTests.cs" /> diff --git a/src/libraries/System.Runtime/tests/System/Numerics/GenericMathDimHelpers.cs b/src/libraries/System.Runtime/tests/System/Numerics/GenericMathDimHelpers.cs index c072ce36ad2..058bba1d255 100644 --- a/src/libraries/System.Runtime/tests/System/Numerics/GenericMathDimHelpers.cs +++ b/src/libraries/System.Runtime/tests/System/Numerics/GenericMathDimHelpers.cs @@ -96,4 +96,176 @@ namespace System.Numerics.Tests static bool IComparisonOperators<BinaryNumberDimHelper, BinaryNumberDimHelper, bool>.operator >=(BinaryNumberDimHelper left, BinaryNumberDimHelper right) => throw new NotImplementedException(); } + public struct FloatingPointDimHelper : IFloatingPoint<FloatingPointDimHelper> + { + public float Value; + + public FloatingPointDimHelper(float value) + { + Value = value; + } + + static FloatingPointDimHelper IFloatingPoint<FloatingPointDimHelper>.Round(FloatingPointDimHelper x, int digits, MidpointRounding mode) + => new FloatingPointDimHelper(float.Round(x.Value, digits, mode)); + + // + // The below are all not used for existing Dim tests, so they stay unimplemented + // + + static FloatingPointDimHelper IFloatingPointConstants<FloatingPointDimHelper>.E => throw new NotImplementedException(); + static FloatingPointDimHelper IFloatingPointConstants<FloatingPointDimHelper>.Pi => throw new NotImplementedException(); + static FloatingPointDimHelper IFloatingPointConstants<FloatingPointDimHelper>.Tau => throw new NotImplementedException(); + static FloatingPointDimHelper ISignedNumber<FloatingPointDimHelper>.NegativeOne => throw new NotImplementedException(); + static FloatingPointDimHelper INumberBase<FloatingPointDimHelper>.One => throw new NotImplementedException(); + static int INumberBase<FloatingPointDimHelper>.Radix => throw new NotImplementedException(); + static FloatingPointDimHelper INumberBase<FloatingPointDimHelper>.Zero => throw new NotImplementedException(); + static FloatingPointDimHelper IAdditiveIdentity<FloatingPointDimHelper, FloatingPointDimHelper>.AdditiveIdentity => throw new NotImplementedException(); + static FloatingPointDimHelper IMultiplicativeIdentity<FloatingPointDimHelper, FloatingPointDimHelper>.MultiplicativeIdentity => throw new NotImplementedException(); + + static FloatingPointDimHelper INumberBase<FloatingPointDimHelper>.Abs(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsCanonical(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsComplexNumber(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsEvenInteger(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsFinite(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsImaginaryNumber(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsInfinity(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsInteger(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsNaN(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsNegative(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsNegativeInfinity(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsNormal(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsOddInteger(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsPositive(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsPositiveInfinity(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsRealNumber(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsSubnormal(FloatingPointDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.IsZero(FloatingPointDimHelper value) => throw new NotImplementedException(); + static FloatingPointDimHelper INumberBase<FloatingPointDimHelper>.MaxMagnitude(FloatingPointDimHelper x, FloatingPointDimHelper y) => throw new NotImplementedException(); + static FloatingPointDimHelper INumberBase<FloatingPointDimHelper>.MaxMagnitudeNumber(FloatingPointDimHelper x, FloatingPointDimHelper y) => throw new NotImplementedException(); + static FloatingPointDimHelper INumberBase<FloatingPointDimHelper>.MinMagnitude(FloatingPointDimHelper x, FloatingPointDimHelper y) => throw new NotImplementedException(); + static FloatingPointDimHelper INumberBase<FloatingPointDimHelper>.MinMagnitudeNumber(FloatingPointDimHelper x, FloatingPointDimHelper y) => throw new NotImplementedException(); + static FloatingPointDimHelper INumberBase<FloatingPointDimHelper>.Parse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider) => throw new NotImplementedException(); + static FloatingPointDimHelper INumberBase<FloatingPointDimHelper>.Parse(string s, NumberStyles style, IFormatProvider? provider) => throw new NotImplementedException(); + static FloatingPointDimHelper ISpanParsable<FloatingPointDimHelper>.Parse(ReadOnlySpan<char> s, IFormatProvider? provider) => throw new NotImplementedException(); + static FloatingPointDimHelper IParsable<FloatingPointDimHelper>.Parse(string s, IFormatProvider? provider) => throw new NotImplementedException(); + + static bool INumberBase<FloatingPointDimHelper>.TryConvertFromChecked<TOther>(TOther value, out FloatingPointDimHelper result) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.TryConvertFromSaturating<TOther>(TOther value, out FloatingPointDimHelper result) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.TryConvertFromTruncating<TOther>(TOther value, out FloatingPointDimHelper result) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.TryConvertToChecked<TOther>(FloatingPointDimHelper value, out TOther result) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.TryConvertToSaturating<TOther>(FloatingPointDimHelper value, out TOther result) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.TryConvertToTruncating<TOther>(FloatingPointDimHelper value, out TOther result) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out FloatingPointDimHelper result) => throw new NotImplementedException(); + static bool INumberBase<FloatingPointDimHelper>.TryParse(string? s, NumberStyles style, IFormatProvider? provider, out FloatingPointDimHelper result) => throw new NotImplementedException(); + static bool ISpanParsable<FloatingPointDimHelper>.TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out FloatingPointDimHelper result) => throw new NotImplementedException(); + static bool IParsable<FloatingPointDimHelper>.TryParse(string? s, IFormatProvider? provider, out FloatingPointDimHelper result) => throw new NotImplementedException(); + int IComparable.CompareTo(object? obj) => throw new NotImplementedException(); + int IComparable<FloatingPointDimHelper>.CompareTo(FloatingPointDimHelper other) => throw new NotImplementedException(); + bool IEquatable<FloatingPointDimHelper>.Equals(FloatingPointDimHelper other) => throw new NotImplementedException(); + int IFloatingPoint<FloatingPointDimHelper>.GetExponentByteCount() => throw new NotImplementedException(); + int IFloatingPoint<FloatingPointDimHelper>.GetExponentShortestBitLength() => throw new NotImplementedException(); + int IFloatingPoint<FloatingPointDimHelper>.GetSignificandBitLength() => throw new NotImplementedException(); + int IFloatingPoint<FloatingPointDimHelper>.GetSignificandByteCount() => throw new NotImplementedException(); + string IFormattable.ToString(string? format, IFormatProvider? formatProvider) => throw new NotImplementedException(); + bool ISpanFormattable.TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider) => throw new NotImplementedException(); + bool IFloatingPoint<FloatingPointDimHelper>.TryWriteExponentBigEndian(Span<byte> destination, out int bytesWritten) => throw new NotImplementedException(); + bool IFloatingPoint<FloatingPointDimHelper>.TryWriteExponentLittleEndian(Span<byte> destination, out int bytesWritten) => throw new NotImplementedException(); + bool IFloatingPoint<FloatingPointDimHelper>.TryWriteSignificandBigEndian(Span<byte> destination, out int bytesWritten) => throw new NotImplementedException(); + bool IFloatingPoint<FloatingPointDimHelper>.TryWriteSignificandLittleEndian(Span<byte> destination, out int bytesWritten) => throw new NotImplementedException(); + + static FloatingPointDimHelper IUnaryPlusOperators<FloatingPointDimHelper, FloatingPointDimHelper>.operator +(FloatingPointDimHelper value) => throw new NotImplementedException(); + static FloatingPointDimHelper IAdditionOperators<FloatingPointDimHelper, FloatingPointDimHelper, FloatingPointDimHelper>.operator +(FloatingPointDimHelper left, FloatingPointDimHelper right) => throw new NotImplementedException(); + static FloatingPointDimHelper IUnaryNegationOperators<FloatingPointDimHelper, FloatingPointDimHelper>.operator -(FloatingPointDimHelper value) => throw new NotImplementedException(); + static FloatingPointDimHelper ISubtractionOperators<FloatingPointDimHelper, FloatingPointDimHelper, FloatingPointDimHelper>.operator -(FloatingPointDimHelper left, FloatingPointDimHelper right) => throw new NotImplementedException(); + static FloatingPointDimHelper IIncrementOperators<FloatingPointDimHelper>.operator ++(FloatingPointDimHelper value) => throw new NotImplementedException(); + static FloatingPointDimHelper IDecrementOperators<FloatingPointDimHelper>.operator --(FloatingPointDimHelper value) => throw new NotImplementedException(); + static FloatingPointDimHelper IMultiplyOperators<FloatingPointDimHelper, FloatingPointDimHelper, FloatingPointDimHelper>.operator *(FloatingPointDimHelper left, FloatingPointDimHelper right) => throw new NotImplementedException(); + static FloatingPointDimHelper IDivisionOperators<FloatingPointDimHelper, FloatingPointDimHelper, FloatingPointDimHelper>.operator /(FloatingPointDimHelper left, FloatingPointDimHelper right) => throw new NotImplementedException(); + static FloatingPointDimHelper IModulusOperators<FloatingPointDimHelper, FloatingPointDimHelper, FloatingPointDimHelper>.operator %(FloatingPointDimHelper left, FloatingPointDimHelper right) => throw new NotImplementedException(); + static bool IEqualityOperators<FloatingPointDimHelper, FloatingPointDimHelper, bool>.operator ==(FloatingPointDimHelper left, FloatingPointDimHelper right) => throw new NotImplementedException(); + static bool IEqualityOperators<FloatingPointDimHelper, FloatingPointDimHelper, bool>.operator !=(FloatingPointDimHelper left, FloatingPointDimHelper right) => throw new NotImplementedException(); + static bool IComparisonOperators<FloatingPointDimHelper, FloatingPointDimHelper, bool>.operator <(FloatingPointDimHelper left, FloatingPointDimHelper right) => throw new NotImplementedException(); + static bool IComparisonOperators<FloatingPointDimHelper, FloatingPointDimHelper, bool>.operator >(FloatingPointDimHelper left, FloatingPointDimHelper right) => throw new NotImplementedException(); + static bool IComparisonOperators<FloatingPointDimHelper, FloatingPointDimHelper, bool>.operator <=(FloatingPointDimHelper left, FloatingPointDimHelper right) => throw new NotImplementedException(); + static bool IComparisonOperators<FloatingPointDimHelper, FloatingPointDimHelper, bool>.operator >=(FloatingPointDimHelper left, FloatingPointDimHelper right) => throw new NotImplementedException(); + } + + public struct ExponentialFunctionsDimHelper : IExponentialFunctions<ExponentialFunctionsDimHelper> + { + public float Value; + + public ExponentialFunctionsDimHelper(float value) + { + Value = value; + } + + static ExponentialFunctionsDimHelper IExponentialFunctions<ExponentialFunctionsDimHelper>.Exp10(ExponentialFunctionsDimHelper x) => new ExponentialFunctionsDimHelper(float.Exp10(x.Value)); + static ExponentialFunctionsDimHelper INumberBase<ExponentialFunctionsDimHelper>.One => new ExponentialFunctionsDimHelper(1f); + static ExponentialFunctionsDimHelper ISubtractionOperators<ExponentialFunctionsDimHelper, ExponentialFunctionsDimHelper, ExponentialFunctionsDimHelper>.operator -(ExponentialFunctionsDimHelper left, ExponentialFunctionsDimHelper right) + => new ExponentialFunctionsDimHelper(left.Value - right.Value); + + // + // The below are all not used for existing Dim tests, so they stay unimplemented + // + + static ExponentialFunctionsDimHelper IFloatingPointConstants<ExponentialFunctionsDimHelper>.E => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper IFloatingPointConstants<ExponentialFunctionsDimHelper>.Pi => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper IFloatingPointConstants<ExponentialFunctionsDimHelper>.Tau => throw new NotImplementedException(); + static int INumberBase<ExponentialFunctionsDimHelper>.Radix => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper INumberBase<ExponentialFunctionsDimHelper>.Zero => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper IAdditiveIdentity<ExponentialFunctionsDimHelper, ExponentialFunctionsDimHelper>.AdditiveIdentity => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper IMultiplicativeIdentity<ExponentialFunctionsDimHelper, ExponentialFunctionsDimHelper>.MultiplicativeIdentity => throw new NotImplementedException(); + + static ExponentialFunctionsDimHelper INumberBase<ExponentialFunctionsDimHelper>.Abs(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper IExponentialFunctions<ExponentialFunctionsDimHelper>.Exp(ExponentialFunctionsDimHelper x) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper IExponentialFunctions<ExponentialFunctionsDimHelper>.Exp2(ExponentialFunctionsDimHelper x) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsCanonical(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsComplexNumber(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsEvenInteger(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsFinite(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsImaginaryNumber(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsInfinity(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsInteger(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsNaN(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsNegative(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsNegativeInfinity(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsNormal(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsOddInteger(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsPositive(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsPositiveInfinity(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsRealNumber(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsSubnormal(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.IsZero(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper INumberBase<ExponentialFunctionsDimHelper>.MaxMagnitude(ExponentialFunctionsDimHelper x, ExponentialFunctionsDimHelper y) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper INumberBase<ExponentialFunctionsDimHelper>.MaxMagnitudeNumber(ExponentialFunctionsDimHelper x, ExponentialFunctionsDimHelper y) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper INumberBase<ExponentialFunctionsDimHelper>.MinMagnitude(ExponentialFunctionsDimHelper x, ExponentialFunctionsDimHelper y) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper INumberBase<ExponentialFunctionsDimHelper>.MinMagnitudeNumber(ExponentialFunctionsDimHelper x, ExponentialFunctionsDimHelper y) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper INumberBase<ExponentialFunctionsDimHelper>.Parse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper INumberBase<ExponentialFunctionsDimHelper>.Parse(string s, NumberStyles style, IFormatProvider? provider) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper ISpanParsable<ExponentialFunctionsDimHelper>.Parse(ReadOnlySpan<char> s, IFormatProvider? provider) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper IParsable<ExponentialFunctionsDimHelper>.Parse(string s, IFormatProvider? provider) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.TryConvertFromChecked<TOther>(TOther value, out ExponentialFunctionsDimHelper result) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.TryConvertFromSaturating<TOther>(TOther value, out ExponentialFunctionsDimHelper result) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.TryConvertFromTruncating<TOther>(TOther value, out ExponentialFunctionsDimHelper result) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.TryConvertToChecked<TOther>(ExponentialFunctionsDimHelper value, out TOther result) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.TryConvertToSaturating<TOther>(ExponentialFunctionsDimHelper value, out TOther result) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.TryConvertToTruncating<TOther>(ExponentialFunctionsDimHelper value, out TOther result) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out ExponentialFunctionsDimHelper result) => throw new NotImplementedException(); + static bool INumberBase<ExponentialFunctionsDimHelper>.TryParse(string? s, NumberStyles style, IFormatProvider? provider, out ExponentialFunctionsDimHelper result) => throw new NotImplementedException(); + static bool ISpanParsable<ExponentialFunctionsDimHelper>.TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out ExponentialFunctionsDimHelper result) => throw new NotImplementedException(); + static bool IParsable<ExponentialFunctionsDimHelper>.TryParse(string? s, IFormatProvider? provider, out ExponentialFunctionsDimHelper result) => throw new NotImplementedException(); + bool IEquatable<ExponentialFunctionsDimHelper>.Equals(ExponentialFunctionsDimHelper other) => throw new NotImplementedException(); + string IFormattable.ToString(string? format, IFormatProvider? formatProvider) => throw new NotImplementedException(); + bool ISpanFormattable.TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider) => throw new NotImplementedException(); + + static ExponentialFunctionsDimHelper IUnaryPlusOperators<ExponentialFunctionsDimHelper, ExponentialFunctionsDimHelper>.operator +(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper IAdditionOperators<ExponentialFunctionsDimHelper, ExponentialFunctionsDimHelper, ExponentialFunctionsDimHelper>.operator +(ExponentialFunctionsDimHelper left, ExponentialFunctionsDimHelper right) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper IUnaryNegationOperators<ExponentialFunctionsDimHelper, ExponentialFunctionsDimHelper>.operator -(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper IIncrementOperators<ExponentialFunctionsDimHelper>.operator ++(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper IDecrementOperators<ExponentialFunctionsDimHelper>.operator --(ExponentialFunctionsDimHelper value) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper IMultiplyOperators<ExponentialFunctionsDimHelper, ExponentialFunctionsDimHelper, ExponentialFunctionsDimHelper>.operator *(ExponentialFunctionsDimHelper left, ExponentialFunctionsDimHelper right) => throw new NotImplementedException(); + static ExponentialFunctionsDimHelper IDivisionOperators<ExponentialFunctionsDimHelper, ExponentialFunctionsDimHelper, ExponentialFunctionsDimHelper>.operator /(ExponentialFunctionsDimHelper left, ExponentialFunctionsDimHelper right) => throw new NotImplementedException(); + static bool IEqualityOperators<ExponentialFunctionsDimHelper, ExponentialFunctionsDimHelper, bool>.operator ==(ExponentialFunctionsDimHelper left, ExponentialFunctionsDimHelper right) => throw new NotImplementedException(); + static bool IEqualityOperators<ExponentialFunctionsDimHelper, ExponentialFunctionsDimHelper, bool>.operator !=(ExponentialFunctionsDimHelper left, ExponentialFunctionsDimHelper right) => throw new NotImplementedException(); + } } diff --git a/src/libraries/System.Runtime/tests/System/Numerics/IExponentialFunctionsTests.cs b/src/libraries/System.Runtime/tests/System/Numerics/IExponentialFunctionsTests.cs new file mode 100644 index 00000000000..6c2096cf88d --- /dev/null +++ b/src/libraries/System.Runtime/tests/System/Numerics/IExponentialFunctionsTests.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Xunit; + +namespace System.Numerics.Tests +{ + public sealed class IExponentialFunctionsTests + { + const float baseValue = 2.1f; + static readonly ExponentialFunctionsDimHelper helperValue = new ExponentialFunctionsDimHelper(baseValue); + + [Fact] + public static void Exp10M1Test() + { + Assert.Equal(float.Exp10M1(baseValue), ExponentialFunctionsHelper<ExponentialFunctionsDimHelper>.Exp10M1(helperValue).Value); + } + } +} diff --git a/src/libraries/System.Runtime/tests/System/Numerics/IFloatingPointTests.cs b/src/libraries/System.Runtime/tests/System/Numerics/IFloatingPointTests.cs new file mode 100644 index 00000000000..6085d5b29d0 --- /dev/null +++ b/src/libraries/System.Runtime/tests/System/Numerics/IFloatingPointTests.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Xunit; + +namespace System.Numerics.Tests +{ + public sealed class IFloatingPointTests + { + const float baseValue = 5.5f; + static readonly FloatingPointDimHelper helperValue = new FloatingPointDimHelper(baseValue); + + [Fact] + public static void AwayFromZeroRoundingTest() + { + Assert.Equal(float.Round(baseValue, MidpointRounding.AwayFromZero), FloatingPointHelper<FloatingPointDimHelper>.Round(helperValue, MidpointRounding.AwayFromZero).Value); + } + + [Fact] + public static void ToEvenRoundingTest() + { + Assert.Equal(float.Round(baseValue, MidpointRounding.ToEven), FloatingPointHelper<FloatingPointDimHelper>.Round(helperValue, MidpointRounding.ToEven).Value); + } + + [Fact] + public static void ToNegativeInfinityRoundingTest() + { + Assert.Equal(float.Round(baseValue, MidpointRounding.ToNegativeInfinity), FloatingPointHelper<FloatingPointDimHelper>.Round(helperValue, MidpointRounding.ToNegativeInfinity).Value); + } + + [Fact] + public static void ToPositiveRoundingTest() + { + Assert.Equal(float.Round(baseValue, MidpointRounding.ToPositiveInfinity), FloatingPointHelper<FloatingPointDimHelper>.Round(helperValue, MidpointRounding.ToPositiveInfinity).Value); + } + + [Fact] + public static void ToZeroRoundingTest() + { + Assert.Equal(float.Round(baseValue, MidpointRounding.ToZero), FloatingPointHelper<FloatingPointDimHelper>.Round(helperValue, MidpointRounding.ToZero).Value); + } + } +} |