mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-22 20:38:47 +00:00
style: move MethodImplOptions to resource file
Prevents repetition through #if directives in every file
This commit is contained in:
parent
b8c3a5121a
commit
5e4af9a9e1
@ -27,11 +27,7 @@ public static class Color32Extensions
|
|||||||
/// When this method returns, contains the <see cref="Color32.b" /> component of <paramref name="color" />.
|
/// When this method returns, contains the <see cref="Color32.b" /> component of <paramref name="color" />.
|
||||||
/// </param>
|
/// </param>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static void Deconstruct(this Color32 color, out byte a, out byte r, out byte g, out byte b)
|
public static void Deconstruct(this Color32 color, out byte a, out byte r, out byte g, out byte b)
|
||||||
{
|
{
|
||||||
a = color.a;
|
a = color.a;
|
||||||
@ -52,11 +48,7 @@ public static class Color32Extensions
|
|||||||
/// When this method returns, contains the <see cref="Color32.b" /> component of <paramref name="color" />.
|
/// When this method returns, contains the <see cref="Color32.b" /> component of <paramref name="color" />.
|
||||||
/// </param>
|
/// </param>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static void Deconstruct(this Color32 color, out byte r, out byte g, out byte b)
|
public static void Deconstruct(this Color32 color, out byte r, out byte g, out byte b)
|
||||||
{
|
{
|
||||||
r = color.r;
|
r = color.r;
|
||||||
|
@ -27,11 +27,7 @@ public static class ColorExtensions
|
|||||||
/// When this method returns, contains the <see cref="Color.b" /> component of <paramref name="color" />.
|
/// When this method returns, contains the <see cref="Color.b" /> component of <paramref name="color" />.
|
||||||
/// </param>
|
/// </param>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static void Deconstruct(this Color color, out float a, out float r, out float g, out float b)
|
public static void Deconstruct(this Color color, out float a, out float r, out float g, out float b)
|
||||||
{
|
{
|
||||||
a = color.a;
|
a = color.a;
|
||||||
@ -52,11 +48,7 @@ public static class ColorExtensions
|
|||||||
/// When this method returns, contains the <see cref="Color.b" /> component of <paramref name="color" />.
|
/// When this method returns, contains the <see cref="Color.b" /> component of <paramref name="color" />.
|
||||||
/// </param>
|
/// </param>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static void Deconstruct(this Color color, out float r, out float g, out float b)
|
public static void Deconstruct(this Color color, out float r, out float g, out float b)
|
||||||
{
|
{
|
||||||
r = color.r;
|
r = color.r;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
using System.Runtime.Intrinsics;
|
using System.Runtime.Intrinsics;
|
||||||
@ -22,11 +23,7 @@ public static class ByteExtensions
|
|||||||
/// <param name="value">The value to unpack.</param>
|
/// <param name="value">The value to unpack.</param>
|
||||||
/// <returns>An array of <see cref="bool" /> with length 8.</returns>
|
/// <returns>An array of <see cref="bool" /> with length 8.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETCOREAPP3_1_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
public static bool[] Unpack(this byte value)
|
public static bool[] Unpack(this byte value)
|
||||||
{
|
{
|
||||||
var buffer = new bool[Size];
|
var buffer = new bool[Size];
|
||||||
@ -41,11 +38,7 @@ public static class ByteExtensions
|
|||||||
/// <param name="destination">When this method returns, contains the unpacked booleans from <paramref name="value" />.</param>
|
/// <param name="destination">When this method returns, contains the unpacked booleans from <paramref name="value" />.</param>
|
||||||
/// <exception cref="ArgumentException"><paramref name="destination" /> is not large enough to contain the result.</exception>
|
/// <exception cref="ArgumentException"><paramref name="destination" /> is not large enough to contain the result.</exception>
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
#if NETCOREAPP3_1_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
public static void Unpack(this byte value, Span<bool> destination)
|
public static void Unpack(this byte value, Span<bool> destination)
|
||||||
{
|
{
|
||||||
if (destination.Length < Size)
|
if (destination.Length < Size)
|
||||||
@ -64,11 +57,7 @@ public static class ByteExtensions
|
|||||||
UnpackInternal_Fallback(value, destination);
|
UnpackInternal_Fallback(value, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NETCOREAPP3_1_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
internal static void UnpackInternal_Fallback(this byte value, Span<bool> destination)
|
internal static void UnpackInternal_Fallback(this byte value, Span<bool> destination)
|
||||||
{
|
{
|
||||||
for (var index = 0; index < Size; index++)
|
for (var index = 0; index < Size; index++)
|
||||||
@ -78,11 +67,7 @@ public static class ByteExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
#if NETCOREAPP3_1_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
internal unsafe static void UnpackInternal_Ssse3(this byte value, Span<bool> destination)
|
internal unsafe static void UnpackInternal_Ssse3(this byte value, Span<bool> destination)
|
||||||
{
|
{
|
||||||
fixed (bool* pDestination = destination)
|
fixed (bool* pDestination = destination)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
using System.Runtime.Intrinsics;
|
using System.Runtime.Intrinsics;
|
||||||
@ -22,11 +23,7 @@ public static class Int16Extensions
|
|||||||
/// <param name="value">The value to unpack.</param>
|
/// <param name="value">The value to unpack.</param>
|
||||||
/// <returns>An array of <see cref="bool" /> with length 16.</returns>
|
/// <returns>An array of <see cref="bool" /> with length 16.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETCOREAPP3_1_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
public static bool[] Unpack(this short value)
|
public static bool[] Unpack(this short value)
|
||||||
{
|
{
|
||||||
var ret = new bool[Size];
|
var ret = new bool[Size];
|
||||||
@ -41,11 +38,7 @@ public static class Int16Extensions
|
|||||||
/// <param name="destination">When this method returns, contains the unpacked booleans from <paramref name="value" />.</param>
|
/// <param name="destination">When this method returns, contains the unpacked booleans from <paramref name="value" />.</param>
|
||||||
/// <exception cref="ArgumentException"><paramref name="destination" /> is not large enough to contain the result.</exception>
|
/// <exception cref="ArgumentException"><paramref name="destination" /> is not large enough to contain the result.</exception>
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
#if NETCOREAPP3_1_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
public static void Unpack(this short value, Span<bool> destination)
|
public static void Unpack(this short value, Span<bool> destination)
|
||||||
{
|
{
|
||||||
if (destination.Length < Size)
|
if (destination.Length < Size)
|
||||||
@ -64,11 +57,7 @@ public static class Int16Extensions
|
|||||||
UnpackInternal_Fallback(value, destination);
|
UnpackInternal_Fallback(value, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NETCOREAPP3_1_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
internal static void UnpackInternal_Fallback(this short value, Span<bool> destination)
|
internal static void UnpackInternal_Fallback(this short value, Span<bool> destination)
|
||||||
{
|
{
|
||||||
for (var index = 0; index < Size; index++)
|
for (var index = 0; index < Size; index++)
|
||||||
@ -78,11 +67,7 @@ public static class Int16Extensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
#if NETCOREAPP3_1_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
internal unsafe static void UnpackInternal_Ssse3(this short value, Span<bool> destination)
|
internal unsafe static void UnpackInternal_Ssse3(this short value, Span<bool> destination)
|
||||||
{
|
{
|
||||||
fixed (bool* pDestination = destination)
|
fixed (bool* pDestination = destination)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
using System.Runtime.Intrinsics;
|
using System.Runtime.Intrinsics;
|
||||||
@ -22,6 +23,7 @@ public static class Int32Extensions
|
|||||||
/// <param name="value">The value to unpack.</param>
|
/// <param name="value">The value to unpack.</param>
|
||||||
/// <returns>An array of <see cref="bool" /> with length 32.</returns>
|
/// <returns>An array of <see cref="bool" /> with length 32.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static bool[] Unpack(this int value)
|
public static bool[] Unpack(this int value)
|
||||||
{
|
{
|
||||||
var ret = new bool[Size];
|
var ret = new bool[Size];
|
||||||
@ -36,6 +38,7 @@ public static class Int32Extensions
|
|||||||
/// <param name="destination">When this method returns, contains the unpacked booleans from <paramref name="value" />.</param>
|
/// <param name="destination">When this method returns, contains the unpacked booleans from <paramref name="value" />.</param>
|
||||||
/// <exception cref="ArgumentException"><paramref name="destination" /> is not large enough to contain the result.</exception>
|
/// <exception cref="ArgumentException"><paramref name="destination" /> is not large enough to contain the result.</exception>
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static void Unpack(this int value, Span<bool> destination)
|
public static void Unpack(this int value, Span<bool> destination)
|
||||||
{
|
{
|
||||||
if (destination.Length < Size)
|
if (destination.Length < Size)
|
||||||
@ -60,11 +63,7 @@ public static class Int32Extensions
|
|||||||
UnpackInternal_Fallback(value, destination);
|
UnpackInternal_Fallback(value, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NETCOREAPP3_1_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
internal static void UnpackInternal_Fallback(this int value, Span<bool> destination)
|
internal static void UnpackInternal_Fallback(this int value, Span<bool> destination)
|
||||||
{
|
{
|
||||||
for (var index = 0; index < Size; index++)
|
for (var index = 0; index < Size; index++)
|
||||||
@ -74,11 +73,7 @@ public static class Int32Extensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
#if NETCOREAPP3_1_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
internal static unsafe void UnpackInternal_Ssse3(this int value, Span<bool> destination)
|
internal static unsafe void UnpackInternal_Ssse3(this int value, Span<bool> destination)
|
||||||
{
|
{
|
||||||
fixed (bool* pDestination = destination)
|
fixed (bool* pDestination = destination)
|
||||||
|
13
X10D/src/CompilerServices/CompilerResources.cs
Normal file
13
X10D/src/CompilerServices/CompilerResources.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
namespace X10D.CompilerServices;
|
||||||
|
|
||||||
|
internal static class CompilerResources
|
||||||
|
{
|
||||||
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
|
public const MethodImplOptions MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining |
|
||||||
|
System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization;
|
||||||
|
#else
|
||||||
|
public const MethodImplOptions MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining;
|
||||||
|
#endif
|
||||||
|
}
|
@ -4,6 +4,7 @@ using System.Diagnostics.Contracts;
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.Intrinsics;
|
using System.Runtime.Intrinsics;
|
||||||
using System.Runtime.Intrinsics.X86;
|
using System.Runtime.Intrinsics.X86;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Core;
|
namespace X10D.Core;
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ public static class IntrinsicExtensions
|
|||||||
/// A <see cref="Vector64{T}"/> of <see langword="byte"/> which remapped back to 0 and 1 based on boolean truthiness.
|
/// A <see cref="Vector64{T}"/> of <see langword="byte"/> which remapped back to 0 and 1 based on boolean truthiness.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static Vector64<byte> CorrectBoolean(this Vector64<byte> vector)
|
public static Vector64<byte> CorrectBoolean(this Vector64<byte> vector)
|
||||||
{
|
{
|
||||||
Vector64<byte> output = IntrinsicUtility.GetUninitializedVector64<byte>();
|
Vector64<byte> output = IntrinsicUtility.GetUninitializedVector64<byte>();
|
||||||
@ -64,7 +65,7 @@ public static class IntrinsicExtensions
|
|||||||
/// A <see cref="Vector128{T}"/> of <see langword="byte"/> which remapped back to 0 and 1 based on boolean truthiness.
|
/// A <see cref="Vector128{T}"/> of <see langword="byte"/> which remapped back to 0 and 1 based on boolean truthiness.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public static Vector128<byte> CorrectBoolean(this Vector128<byte> vector)
|
public static Vector128<byte> CorrectBoolean(this Vector128<byte> vector)
|
||||||
{
|
{
|
||||||
@ -87,7 +88,7 @@ public static class IntrinsicExtensions
|
|||||||
/// A <see cref="Vector256{T}"/> of <see langword="byte"/> which remapped back to 0 and 1 based on boolean truthiness.
|
/// A <see cref="Vector256{T}"/> of <see langword="byte"/> which remapped back to 0 and 1 based on boolean truthiness.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public static Vector256<byte> CorrectBoolean(this Vector256<byte> vector)
|
public static Vector256<byte> CorrectBoolean(this Vector256<byte> vector)
|
||||||
{
|
{
|
||||||
@ -111,7 +112,7 @@ public static class IntrinsicExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public static Vector128<ulong> ReverseElements(this Vector128<ulong> vector)
|
public static Vector128<ulong> ReverseElements(this Vector128<ulong> vector)
|
||||||
{
|
{
|
||||||
@ -119,7 +120,7 @@ public static class IntrinsicExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector128<byte> CorrectBooleanInternal_Fallback(this Vector128<byte> vector)
|
internal static Vector128<byte> CorrectBooleanInternal_Fallback(this Vector128<byte> vector)
|
||||||
{
|
{
|
||||||
Vector128<byte> output = IntrinsicUtility.GetUninitializedVector128<byte>();
|
Vector128<byte> output = IntrinsicUtility.GetUninitializedVector128<byte>();
|
||||||
@ -134,7 +135,7 @@ public static class IntrinsicExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector128<byte> CorrectBooleanInternal_Sse2(this Vector128<byte> vector)
|
internal static Vector128<byte> CorrectBooleanInternal_Sse2(this Vector128<byte> vector)
|
||||||
{
|
{
|
||||||
Vector128<byte> cmp = Sse2.CompareEqual(vector, Vector128<byte>.Zero);
|
Vector128<byte> cmp = Sse2.CompareEqual(vector, Vector128<byte>.Zero);
|
||||||
@ -144,7 +145,7 @@ public static class IntrinsicExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector256<byte> CorrectBooleanInternal_Fallback(this Vector256<byte> vector)
|
internal static Vector256<byte> CorrectBooleanInternal_Fallback(this Vector256<byte> vector)
|
||||||
{
|
{
|
||||||
Vector256<byte> output = IntrinsicUtility.GetUninitializedVector256<byte>();
|
Vector256<byte> output = IntrinsicUtility.GetUninitializedVector256<byte>();
|
||||||
@ -159,7 +160,7 @@ public static class IntrinsicExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector256<byte> CorrectBooleanInternal_Avx2(this Vector256<byte> vector)
|
internal static Vector256<byte> CorrectBooleanInternal_Avx2(this Vector256<byte> vector)
|
||||||
{
|
{
|
||||||
Vector256<byte> cmp = Avx2.CompareEqual(vector, Vector256<byte>.Zero);
|
Vector256<byte> cmp = Avx2.CompareEqual(vector, Vector256<byte>.Zero);
|
||||||
@ -169,7 +170,7 @@ public static class IntrinsicExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector128<ulong> ReverseElementsInternal_Fallback(this Vector128<ulong> vector)
|
internal static Vector128<ulong> ReverseElementsInternal_Fallback(this Vector128<ulong> vector)
|
||||||
{
|
{
|
||||||
Vector128<ulong> output = IntrinsicUtility.GetUninitializedVector128<ulong>();
|
Vector128<ulong> output = IntrinsicUtility.GetUninitializedVector128<ulong>();
|
||||||
@ -181,7 +182,7 @@ public static class IntrinsicExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector128<ulong> ReverseElementsInternal_Sse2(this Vector128<ulong> vector)
|
internal static Vector128<ulong> ReverseElementsInternal_Sse2(this Vector128<ulong> vector)
|
||||||
{
|
{
|
||||||
return Sse2.Shuffle(vector.AsDouble(), vector.AsDouble(), 0b01).AsUInt64();
|
return Sse2.Shuffle(vector.AsDouble(), vector.AsDouble(), 0b01).AsUInt64();
|
||||||
|
@ -5,6 +5,7 @@ using System.Diagnostics.Contracts;
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.Intrinsics;
|
using System.Runtime.Intrinsics;
|
||||||
using System.Runtime.Intrinsics.X86;
|
using System.Runtime.Intrinsics.X86;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Core;
|
namespace X10D.Core;
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ public static class IntrinsicUtility
|
|||||||
/// <returns>The truncated product vector.</returns>
|
/// <returns>The truncated product vector.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public static Vector128<ulong> Multiply(Vector128<ulong> left, Vector128<ulong> right)
|
public static Vector128<ulong> Multiply(Vector128<ulong> left, Vector128<ulong> right)
|
||||||
{
|
{
|
||||||
@ -63,7 +64,7 @@ public static class IntrinsicUtility
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public static Vector256<ulong> Multiply(Vector256<ulong> lhs, Vector256<ulong> rhs)
|
public static Vector256<ulong> Multiply(Vector256<ulong> lhs, Vector256<ulong> rhs)
|
||||||
{
|
{
|
||||||
@ -91,7 +92,7 @@ public static class IntrinsicUtility
|
|||||||
/// A <see cref="Vector128{T}"/> of <see langword="long"/> whose elements is 64-bit truncated product of lhs and rhs.
|
/// A <see cref="Vector128{T}"/> of <see langword="long"/> whose elements is 64-bit truncated product of lhs and rhs.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static Vector128<long> Multiply(Vector128<long> lhs, Vector128<long> rhs)
|
public static Vector128<long> Multiply(Vector128<long> lhs, Vector128<long> rhs)
|
||||||
{
|
{
|
||||||
return Multiply(lhs.AsUInt64(), rhs.AsUInt64()).AsInt64();
|
return Multiply(lhs.AsUInt64(), rhs.AsUInt64()).AsInt64();
|
||||||
@ -115,7 +116,7 @@ public static class IntrinsicUtility
|
|||||||
/// A <see cref="Vector256{T}"/> of <see langword="ulong"/> whose elements is 64-bit truncated product of lhs and rhs.
|
/// A <see cref="Vector256{T}"/> of <see langword="ulong"/> whose elements is 64-bit truncated product of lhs and rhs.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static Vector256<long> Multiply(Vector256<long> lhs, Vector256<long> rhs)
|
public static Vector256<long> Multiply(Vector256<long> lhs, Vector256<long> rhs)
|
||||||
{
|
{
|
||||||
return Multiply(lhs.AsUInt64(), rhs.AsUInt64()).AsInt64();
|
return Multiply(lhs.AsUInt64(), rhs.AsUInt64()).AsInt64();
|
||||||
@ -141,7 +142,7 @@ public static class IntrinsicUtility
|
|||||||
/// elements in lhs and rhs.
|
/// elements in lhs and rhs.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public static Vector128<int> HorizontalOr(Vector128<int> left, Vector128<int> right)
|
public static Vector128<int> HorizontalOr(Vector128<int> left, Vector128<int> right)
|
||||||
{
|
{
|
||||||
@ -172,7 +173,7 @@ public static class IntrinsicUtility
|
|||||||
/// elements in lhs and rhs.
|
/// elements in lhs and rhs.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public static Vector128<uint> HorizontalOr(Vector128<uint> left, Vector128<uint> right)
|
public static Vector128<uint> HorizontalOr(Vector128<uint> left, Vector128<uint> right)
|
||||||
{
|
{
|
||||||
@ -180,7 +181,7 @@ public static class IntrinsicUtility
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper methods
|
// Helper methods
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector64<T> GetUninitializedVector64<T>() where T : struct
|
internal static Vector64<T> GetUninitializedVector64<T>() where T : struct
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -191,7 +192,7 @@ public static class IntrinsicUtility
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector128<T> GetUninitializedVector128<T>() where T : struct
|
internal static Vector128<T> GetUninitializedVector128<T>() where T : struct
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -202,7 +203,7 @@ public static class IntrinsicUtility
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector256<T> GetUninitializedVector256<T>() where T : struct
|
internal static Vector256<T> GetUninitializedVector256<T>() where T : struct
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -214,7 +215,7 @@ public static class IntrinsicUtility
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector128<int> HorizontalOr_Sse(Vector128<int> left, Vector128<int> right)
|
internal static Vector128<int> HorizontalOr_Sse(Vector128<int> left, Vector128<int> right)
|
||||||
{
|
{
|
||||||
Vector128<float> leftSingle = left.AsSingle();
|
Vector128<float> leftSingle = left.AsSingle();
|
||||||
@ -229,7 +230,7 @@ public static class IntrinsicUtility
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector128<int> HorizontalOrInternal_Fallback(Vector128<int> left, Vector128<int> right)
|
internal static Vector128<int> HorizontalOrInternal_Fallback(Vector128<int> left, Vector128<int> right)
|
||||||
{
|
{
|
||||||
Vector128<int> output = GetUninitializedVector128<int>();
|
Vector128<int> output = GetUninitializedVector128<int>();
|
||||||
@ -249,7 +250,7 @@ public static class IntrinsicUtility
|
|||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector128<ulong> MultiplyInternal_Fallback(Vector128<ulong> left, Vector128<ulong> right)
|
internal static Vector128<ulong> MultiplyInternal_Fallback(Vector128<ulong> left, Vector128<ulong> right)
|
||||||
{
|
{
|
||||||
ulong leftInteger1 = Unsafe.As<Vector128<ulong>, ulong>(ref left);
|
ulong leftInteger1 = Unsafe.As<Vector128<ulong>, ulong>(ref left);
|
||||||
@ -267,7 +268,7 @@ public static class IntrinsicUtility
|
|||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector128<ulong> MultiplyInternal_Sse2(Vector128<ulong> left, Vector128<ulong> right)
|
internal static Vector128<ulong> MultiplyInternal_Sse2(Vector128<ulong> left, Vector128<ulong> right)
|
||||||
{
|
{
|
||||||
// https://stackoverflow.com/questions/17863411/sse-multiplication-of-2-64-bit-integers
|
// https://stackoverflow.com/questions/17863411/sse-multiplication-of-2-64-bit-integers
|
||||||
@ -284,7 +285,7 @@ public static class IntrinsicUtility
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector256<ulong> MultiplyInternal_Fallback(Vector256<ulong> left, Vector256<ulong> right)
|
internal static Vector256<ulong> MultiplyInternal_Fallback(Vector256<ulong> left, Vector256<ulong> right)
|
||||||
{
|
{
|
||||||
Vector256<ulong> output = GetUninitializedVector256<ulong>();
|
Vector256<ulong> output = GetUninitializedVector256<ulong>();
|
||||||
@ -300,7 +301,7 @@ public static class IntrinsicUtility
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static Vector256<ulong> MultiplyInternal_Avx2(Vector256<ulong> left, Vector256<ulong> right)
|
internal static Vector256<ulong> MultiplyInternal_Avx2(Vector256<ulong> left, Vector256<ulong> right)
|
||||||
{
|
{
|
||||||
// https://stackoverflow.com/questions/17863411/sse-multiplication-of-2-64-bit-integers
|
// https://stackoverflow.com/questions/17863411/sse-multiplication-of-2-64-bit-integers
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
using System.Runtime.Intrinsics;
|
using System.Runtime.Intrinsics;
|
||||||
@ -48,11 +49,7 @@ public static class SpanExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentException">The size of <typeparamref name="T" /> is unsupported.</exception>
|
/// <exception cref="ArgumentException">The size of <typeparamref name="T" /> is unsupported.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool Contains<T>(this Span<T> span, T value) where T : struct, Enum
|
public static bool Contains<T>(this Span<T> span, T value) where T : struct, Enum
|
||||||
{
|
{
|
||||||
return Contains((ReadOnlySpan<T>)span, value);
|
return Contains((ReadOnlySpan<T>)span, value);
|
||||||
@ -71,11 +68,7 @@ public static class SpanExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentException">The size of <typeparamref name="T" /> is unsupported.</exception>
|
/// <exception cref="ArgumentException">The size of <typeparamref name="T" /> is unsupported.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
public static bool Contains<T>(this ReadOnlySpan<T> span, T value) where T : struct, Enum
|
public static bool Contains<T>(this ReadOnlySpan<T> span, T value) where T : struct, Enum
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -141,11 +134,7 @@ public static class SpanExtensions
|
|||||||
/// <returns>An 8-bit unsigned integer containing the packed booleans.</returns>
|
/// <returns>An 8-bit unsigned integer containing the packed booleans.</returns>
|
||||||
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 8 elements.</exception>
|
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 8 elements.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
public static byte PackByte(this Span<bool> source)
|
public static byte PackByte(this Span<bool> source)
|
||||||
{
|
{
|
||||||
return PackByte((ReadOnlySpan<bool>)source);
|
return PackByte((ReadOnlySpan<bool>)source);
|
||||||
@ -158,11 +147,7 @@ public static class SpanExtensions
|
|||||||
/// <returns>An 8-bit unsigned integer containing the packed booleans.</returns>
|
/// <returns>An 8-bit unsigned integer containing the packed booleans.</returns>
|
||||||
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 8 elements.</exception>
|
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 8 elements.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public static byte PackByte(this ReadOnlySpan<bool> source)
|
public static byte PackByte(this ReadOnlySpan<bool> source)
|
||||||
{
|
{
|
||||||
@ -216,11 +201,7 @@ public static class SpanExtensions
|
|||||||
/// <returns>A 16-bit signed integer containing the packed booleans.</returns>
|
/// <returns>A 16-bit signed integer containing the packed booleans.</returns>
|
||||||
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 16 elements.</exception>
|
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 16 elements.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public static short PackInt16(this ReadOnlySpan<bool> source)
|
public static short PackInt16(this ReadOnlySpan<bool> source)
|
||||||
{
|
{
|
||||||
@ -259,11 +240,7 @@ public static class SpanExtensions
|
|||||||
/// <returns>A 32-bit signed integer containing the packed booleans.</returns>
|
/// <returns>A 32-bit signed integer containing the packed booleans.</returns>
|
||||||
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 32 elements.</exception>
|
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 32 elements.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
public static int PackInt32(this Span<bool> source)
|
public static int PackInt32(this Span<bool> source)
|
||||||
{
|
{
|
||||||
return PackInt32((ReadOnlySpan<bool>)source);
|
return PackInt32((ReadOnlySpan<bool>)source);
|
||||||
@ -276,11 +253,7 @@ public static class SpanExtensions
|
|||||||
/// <returns>A 32-bit signed integer containing the packed booleans.</returns>
|
/// <returns>A 32-bit signed integer containing the packed booleans.</returns>
|
||||||
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 32 elements.</exception>
|
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 32 elements.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public static int PackInt32(this ReadOnlySpan<bool> source)
|
public static int PackInt32(this ReadOnlySpan<bool> source)
|
||||||
{
|
{
|
||||||
@ -331,11 +304,7 @@ public static class SpanExtensions
|
|||||||
/// <returns>A 64-bit signed integer containing the packed booleans.</returns>
|
/// <returns>A 64-bit signed integer containing the packed booleans.</returns>
|
||||||
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 64 elements.</exception>
|
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 64 elements.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
public static long PackInt64(this Span<bool> source)
|
public static long PackInt64(this Span<bool> source)
|
||||||
{
|
{
|
||||||
return PackInt64((ReadOnlySpan<bool>)source);
|
return PackInt64((ReadOnlySpan<bool>)source);
|
||||||
@ -348,11 +317,7 @@ public static class SpanExtensions
|
|||||||
/// <returns>A 64-bit signed integer containing the packed booleans.</returns>
|
/// <returns>A 64-bit signed integer containing the packed booleans.</returns>
|
||||||
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 64 elements.</exception>
|
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 64 elements.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
public static long PackInt64(this ReadOnlySpan<bool> source)
|
public static long PackInt64(this ReadOnlySpan<bool> source)
|
||||||
{
|
{
|
||||||
switch (source.Length)
|
switch (source.Length)
|
||||||
@ -377,11 +342,7 @@ public static class SpanExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
internal static byte PackByteInternal_Fallback(this ReadOnlySpan<bool> source)
|
internal static byte PackByteInternal_Fallback(this ReadOnlySpan<bool> source)
|
||||||
{
|
{
|
||||||
byte result = 0;
|
byte result = 0;
|
||||||
@ -395,11 +356,7 @@ public static class SpanExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
internal static short PackInt16Internal_Fallback(this ReadOnlySpan<bool> source)
|
internal static short PackInt16Internal_Fallback(this ReadOnlySpan<bool> source)
|
||||||
{
|
{
|
||||||
short result = 0;
|
short result = 0;
|
||||||
@ -413,11 +370,7 @@ public static class SpanExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#endif
|
|
||||||
internal static int PackInt32Internal_Fallback(this ReadOnlySpan<bool> source)
|
internal static int PackInt32Internal_Fallback(this ReadOnlySpan<bool> source)
|
||||||
{
|
{
|
||||||
var result = 0;
|
var result = 0;
|
||||||
@ -432,7 +385,7 @@ public static class SpanExtensions
|
|||||||
|
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static byte PackByteInternal_Sse2(this ReadOnlySpan<bool> source)
|
internal static byte PackByteInternal_Sse2(this ReadOnlySpan<bool> source)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
@ -446,7 +399,7 @@ public static class SpanExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static short PackInt16Internal_Sse2(this ReadOnlySpan<bool> source)
|
internal static short PackInt16Internal_Sse2(this ReadOnlySpan<bool> source)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
@ -466,7 +419,7 @@ public static class SpanExtensions
|
|||||||
// dotcover disable
|
// dotcover disable
|
||||||
//NOSONAR
|
//NOSONAR
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static int PackInt32Internal_AdvSimd(this ReadOnlySpan<bool> source)
|
internal static int PackInt32Internal_AdvSimd(this ReadOnlySpan<bool> source)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
@ -493,7 +446,7 @@ public static class SpanExtensions
|
|||||||
// dotcover enable
|
// dotcover enable
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static int PackInt32Internal_Avx2(this ReadOnlySpan<bool> source)
|
internal static int PackInt32Internal_Avx2(this ReadOnlySpan<bool> source)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
@ -518,7 +471,7 @@ public static class SpanExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static int PackInt32Internal_Sse2(this ReadOnlySpan<bool> source)
|
internal static int PackInt32Internal_Sse2(this ReadOnlySpan<bool> source)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
@ -550,7 +503,7 @@ public static class SpanExtensions
|
|||||||
// dotcover disable
|
// dotcover disable
|
||||||
//NOSONAR
|
//NOSONAR
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
internal static byte PackByteInternal_AdvSimd(this ReadOnlySpan<bool> source)
|
internal static byte PackByteInternal_AdvSimd(this ReadOnlySpan<bool> source)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Drawing;
|
namespace X10D.Drawing;
|
||||||
|
|
||||||
@ -26,11 +27,7 @@ public static class ColorExtensions
|
|||||||
/// When this method returns, contains the <see cref="Color.B" /> component of <paramref name="color" />.
|
/// When this method returns, contains the <see cref="Color.B" /> component of <paramref name="color" />.
|
||||||
/// </param>
|
/// </param>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static void Deconstruct(this Color color, out byte a, out byte r, out byte g, out byte b)
|
public static void Deconstruct(this Color color, out byte a, out byte r, out byte g, out byte b)
|
||||||
{
|
{
|
||||||
a = color.A;
|
a = color.A;
|
||||||
@ -51,11 +48,7 @@ public static class ColorExtensions
|
|||||||
/// When this method returns, contains the <see cref="Color.B" /> component of <paramref name="color" />.
|
/// When this method returns, contains the <see cref="Color.B" /> component of <paramref name="color" />.
|
||||||
/// </param>
|
/// </param>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static void Deconstruct(this Color color, out byte r, out byte g, out byte b)
|
public static void Deconstruct(this Color color, out byte r, out byte g, out byte b)
|
||||||
{
|
{
|
||||||
r = color.R;
|
r = color.R;
|
||||||
@ -70,11 +63,7 @@ public static class ColorExtensions
|
|||||||
/// <returns>The closest <see cref="ConsoleColor" />.</returns>
|
/// <returns>The closest <see cref="ConsoleColor" />.</returns>
|
||||||
/// <author>Glenn Slayden, https://stackoverflow.com/a/12340136/1467293</author>
|
/// <author>Glenn Slayden, https://stackoverflow.com/a/12340136/1467293</author>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ConsoleColor GetClosestConsoleColor(this Color color)
|
public static ConsoleColor GetClosestConsoleColor(this Color color)
|
||||||
{
|
{
|
||||||
ConsoleColor result = 0;
|
ConsoleColor result = 0;
|
||||||
@ -121,11 +110,7 @@ public static class ColorExtensions
|
|||||||
/// <param name="color">The color to invert.</param>
|
/// <param name="color">The color to invert.</param>
|
||||||
/// <returns>The inverted color.</returns>
|
/// <returns>The inverted color.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Color Inverted(this Color color)
|
public static Color Inverted(this Color color)
|
||||||
{
|
{
|
||||||
return Color.FromArgb(color.A, 255 - color.R, 255 - color.G, 255 - color.B);
|
return Color.FromArgb(color.A, 255 - color.R, 255 - color.G, 255 - color.B);
|
||||||
@ -143,11 +128,7 @@ public static class ColorExtensions
|
|||||||
/// <see cref="Color.A" /> component is <paramref name="a" />.
|
/// <see cref="Color.A" /> component is <paramref name="a" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Color WithA(this Color color, int a)
|
public static Color WithA(this Color color, int a)
|
||||||
{
|
{
|
||||||
return Color.FromArgb(a, color.R, color.G, color.B);
|
return Color.FromArgb(a, color.R, color.G, color.B);
|
||||||
@ -165,11 +146,7 @@ public static class ColorExtensions
|
|||||||
/// <see cref="Color.B" /> component is <paramref name="b" />.
|
/// <see cref="Color.B" /> component is <paramref name="b" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Color WithB(this Color color, int b)
|
public static Color WithB(this Color color, int b)
|
||||||
{
|
{
|
||||||
return Color.FromArgb(color.A, color.R, color.G, b);
|
return Color.FromArgb(color.A, color.R, color.G, b);
|
||||||
@ -187,11 +164,7 @@ public static class ColorExtensions
|
|||||||
/// <see cref="Color.G" /> component is <paramref name="g" />.
|
/// <see cref="Color.G" /> component is <paramref name="g" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Color WithG(this Color color, int g)
|
public static Color WithG(this Color color, int g)
|
||||||
{
|
{
|
||||||
return Color.FromArgb(color.A, color.R, g, color.B);
|
return Color.FromArgb(color.A, color.R, g, color.B);
|
||||||
@ -209,11 +182,7 @@ public static class ColorExtensions
|
|||||||
/// <see cref="Color.R" /> component is <paramref name="r" />.
|
/// <see cref="Color.R" /> component is <paramref name="r" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Color WithR(this Color color, int r)
|
public static Color WithR(this Color color, int r)
|
||||||
{
|
{
|
||||||
return Color.FromArgb(color.A, r, color.G, color.B);
|
return Color.FromArgb(color.A, r, color.G, color.B);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Drawing;
|
namespace X10D.Drawing;
|
||||||
|
|
||||||
@ -20,11 +21,7 @@ public static class PointExtensions
|
|||||||
/// <see langword="false" />.
|
/// <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOnLine(this Point point, LineF line)
|
public static bool IsOnLine(this Point point, LineF line)
|
||||||
{
|
{
|
||||||
return ((PointF)point).IsOnLine(line);
|
return ((PointF)point).IsOnLine(line);
|
||||||
@ -41,11 +38,7 @@ public static class PointExtensions
|
|||||||
/// <paramref name="end" />; otherwise <see langword="false" />.
|
/// <paramref name="end" />; otherwise <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOnLine(this Point point, PointF start, PointF end)
|
public static bool IsOnLine(this Point point, PointF start, PointF end)
|
||||||
{
|
{
|
||||||
return point.IsOnLine(new LineF(start, end));
|
return point.IsOnLine(new LineF(start, end));
|
||||||
@ -62,11 +55,7 @@ public static class PointExtensions
|
|||||||
/// <paramref name="end" />; otherwise <see langword="false" />.
|
/// <paramref name="end" />; otherwise <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOnLine(this Point point, Vector2 start, Vector2 end)
|
public static bool IsOnLine(this Point point, Vector2 start, Vector2 end)
|
||||||
{
|
{
|
||||||
return point.IsOnLine(new LineF(start, end));
|
return point.IsOnLine(new LineF(start, end));
|
||||||
@ -78,11 +67,7 @@ public static class PointExtensions
|
|||||||
/// <param name="point">The point to convert.</param>
|
/// <param name="point">The point to convert.</param>
|
||||||
/// <returns>The resulting <see cref="Size" />.</returns>
|
/// <returns>The resulting <see cref="Size" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Size ToSize(this Point point)
|
public static Size ToSize(this Point point)
|
||||||
{
|
{
|
||||||
return new Size(point.X, point.Y);
|
return new Size(point.X, point.Y);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
using X10D.Math;
|
using X10D.Math;
|
||||||
|
|
||||||
namespace X10D.Drawing;
|
namespace X10D.Drawing;
|
||||||
@ -21,11 +22,7 @@ public static class PointFExtensions
|
|||||||
/// <see langword="false" />.
|
/// <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOnLine(this PointF point, LineF line)
|
public static bool IsOnLine(this PointF point, LineF line)
|
||||||
{
|
{
|
||||||
(float x1, float x2) = (line.Start.X, line.End.X);
|
(float x1, float x2) = (line.Start.X, line.End.X);
|
||||||
@ -45,11 +42,7 @@ public static class PointFExtensions
|
|||||||
/// <paramref name="end" />; otherwise <see langword="false" />.
|
/// <paramref name="end" />; otherwise <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOnLine(this PointF point, PointF start, PointF end)
|
public static bool IsOnLine(this PointF point, PointF start, PointF end)
|
||||||
{
|
{
|
||||||
return point.IsOnLine(new LineF(start, end));
|
return point.IsOnLine(new LineF(start, end));
|
||||||
@ -66,11 +59,7 @@ public static class PointFExtensions
|
|||||||
/// <paramref name="end" />; otherwise <see langword="false" />.
|
/// <paramref name="end" />; otherwise <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOnLine(this PointF point, Vector2 start, Vector2 end)
|
public static bool IsOnLine(this PointF point, Vector2 start, Vector2 end)
|
||||||
{
|
{
|
||||||
return point.IsOnLine(new LineF(start, end));
|
return point.IsOnLine(new LineF(start, end));
|
||||||
@ -82,11 +71,7 @@ public static class PointFExtensions
|
|||||||
/// <param name="point">The point whose components to round.</param>
|
/// <param name="point">The point whose components to round.</param>
|
||||||
/// <returns>The rounded point.</returns>
|
/// <returns>The rounded point.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static PointF Round(this PointF point)
|
public static PointF Round(this PointF point)
|
||||||
{
|
{
|
||||||
return point.Round(1.0f);
|
return point.Round(1.0f);
|
||||||
@ -99,11 +84,7 @@ public static class PointFExtensions
|
|||||||
/// <param name="nearest">The nearest multiple to which the components should be rounded.</param>
|
/// <param name="nearest">The nearest multiple to which the components should be rounded.</param>
|
||||||
/// <returns>The rounded point.</returns>
|
/// <returns>The rounded point.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static PointF Round(this PointF point, float nearest)
|
public static PointF Round(this PointF point, float nearest)
|
||||||
{
|
{
|
||||||
float x = point.X.Round(nearest);
|
float x = point.X.Round(nearest);
|
||||||
@ -117,11 +98,7 @@ public static class PointFExtensions
|
|||||||
/// <param name="point">The point to convert.</param>
|
/// <param name="point">The point to convert.</param>
|
||||||
/// <returns>The resulting <see cref="SizeF" />.</returns>
|
/// <returns>The resulting <see cref="SizeF" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static SizeF ToSizeF(this PointF point)
|
public static SizeF ToSizeF(this PointF point)
|
||||||
{
|
{
|
||||||
return new SizeF(point.X, point.Y);
|
return new SizeF(point.X, point.Y);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Drawing;
|
namespace X10D.Drawing;
|
||||||
|
|
||||||
@ -16,11 +17,7 @@ public static class SizeExtensions
|
|||||||
/// <param name="size">The size to convert.</param>
|
/// <param name="size">The size to convert.</param>
|
||||||
/// <returns>The resulting <see cref="Point" />.</returns>
|
/// <returns>The resulting <see cref="Point" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Point ToPoint(this Size size)
|
public static Point ToPoint(this Size size)
|
||||||
{
|
{
|
||||||
return new Point(size.Width, size.Height);
|
return new Point(size.Width, size.Height);
|
||||||
@ -32,11 +29,7 @@ public static class SizeExtensions
|
|||||||
/// <param name="size">The size to convert.</param>
|
/// <param name="size">The size to convert.</param>
|
||||||
/// <returns>The resulting <see cref="PointF" />.</returns>
|
/// <returns>The resulting <see cref="PointF" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static PointF ToPointF(this Size size)
|
public static PointF ToPointF(this Size size)
|
||||||
{
|
{
|
||||||
return new PointF(size.Width, size.Height);
|
return new PointF(size.Width, size.Height);
|
||||||
@ -48,11 +41,7 @@ public static class SizeExtensions
|
|||||||
/// <param name="size">The size to convert.</param>
|
/// <param name="size">The size to convert.</param>
|
||||||
/// <returns>The resulting <see cref="Vector2" />.</returns>
|
/// <returns>The resulting <see cref="Vector2" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector2 ToVector2(this Size size)
|
public static Vector2 ToVector2(this Size size)
|
||||||
{
|
{
|
||||||
return new Vector2(size.Width, size.Height);
|
return new Vector2(size.Width, size.Height);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Math;
|
namespace X10D.Math;
|
||||||
|
|
||||||
@ -19,11 +20,7 @@ public static class ByteExtensions
|
|||||||
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static byte DigitalRoot(this byte value)
|
public static byte DigitalRoot(this byte value)
|
||||||
{
|
{
|
||||||
int root = value % 9;
|
int root = value % 9;
|
||||||
@ -36,11 +33,7 @@ public static class ByteExtensions
|
|||||||
/// <param name="value">The value whose factorial to compute.</param>
|
/// <param name="value">The value whose factorial to compute.</param>
|
||||||
/// <returns>The factorial of <paramref name="value" />.</returns>
|
/// <returns>The factorial of <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long Factorial(this byte value)
|
public static long Factorial(this byte value)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
@ -64,11 +57,7 @@ public static class ByteExtensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static byte GreatestCommonFactor(this byte value, byte other)
|
public static byte GreatestCommonFactor(this byte value, byte other)
|
||||||
{
|
{
|
||||||
return (byte)((long)value).GreatestCommonFactor(other);
|
return (byte)((long)value).GreatestCommonFactor(other);
|
||||||
@ -83,11 +72,7 @@ public static class ByteExtensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsEven(this byte value)
|
public static bool IsEven(this byte value)
|
||||||
{
|
{
|
||||||
return (value & 1) == 0;
|
return (value & 1) == 0;
|
||||||
@ -102,11 +87,7 @@ public static class ByteExtensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOdd(this byte value)
|
public static bool IsOdd(this byte value)
|
||||||
{
|
{
|
||||||
return !value.IsEven();
|
return !value.IsEven();
|
||||||
@ -132,11 +113,7 @@ public static class ByteExtensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static byte LowestCommonMultiple(this byte value, byte other)
|
public static byte LowestCommonMultiple(this byte value, byte other)
|
||||||
{
|
{
|
||||||
return (byte)((long)value).LowestCommonMultiple(other);
|
return (byte)((long)value).LowestCommonMultiple(other);
|
||||||
@ -151,11 +128,7 @@ public static class ByteExtensions
|
|||||||
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int MultiplicativePersistence(this byte value)
|
public static int MultiplicativePersistence(this byte value)
|
||||||
{
|
{
|
||||||
return ((long)value).MultiplicativePersistence();
|
return ((long)value).MultiplicativePersistence();
|
||||||
@ -169,11 +142,7 @@ public static class ByteExtensions
|
|||||||
/// <param name="high">The exclusive upper bound.</param>
|
/// <param name="high">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static byte Wrap(this byte value, byte low, byte high)
|
public static byte Wrap(this byte value, byte low, byte high)
|
||||||
{
|
{
|
||||||
return (byte)((ulong)value).Wrap(low, high);
|
return (byte)((ulong)value).Wrap(low, high);
|
||||||
@ -186,11 +155,7 @@ public static class ByteExtensions
|
|||||||
/// <param name="length">The exclusive upper bound.</param>
|
/// <param name="length">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static byte Wrap(this byte value, byte length)
|
public static byte Wrap(this byte value, byte length)
|
||||||
{
|
{
|
||||||
return (byte)((ulong)value).Wrap(length);
|
return (byte)((ulong)value).Wrap(length);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Math;
|
namespace X10D.Math;
|
||||||
|
|
||||||
@ -48,11 +49,7 @@ public static class ComparableExtensions
|
|||||||
/// </example>
|
/// </example>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool Between<T1, T2, T3>(this T1 value, T2 lower, T3 upper,
|
public static bool Between<T1, T2, T3>(this T1 value, T2 lower, T3 upper,
|
||||||
InclusiveOptions inclusiveOptions = InclusiveOptions.None)
|
InclusiveOptions inclusiveOptions = InclusiveOptions.None)
|
||||||
where T1 : IComparable<T2>, IComparable<T3>
|
where T1 : IComparable<T2>, IComparable<T3>
|
||||||
@ -113,11 +110,7 @@ public static class ComparableExtensions
|
|||||||
/// </example>
|
/// </example>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static T Clamp<T>(this T value, T lower, T upper)
|
public static T Clamp<T>(this T value, T lower, T upper)
|
||||||
where T : IComparable<T>
|
where T : IComparable<T>
|
||||||
{
|
{
|
||||||
@ -163,11 +156,7 @@ public static class ComparableExtensions
|
|||||||
/// </example>
|
/// </example>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool GreaterThan<T1, T2>(this T1 value, T2 other)
|
public static bool GreaterThan<T1, T2>(this T1 value, T2 other)
|
||||||
where T1 : IComparable<T2>
|
where T1 : IComparable<T2>
|
||||||
{
|
{
|
||||||
@ -206,11 +195,7 @@ public static class ComparableExtensions
|
|||||||
/// </example>
|
/// </example>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool GreaterThanOrEqualTo<T1, T2>(this T1 value, T2 other)
|
public static bool GreaterThanOrEqualTo<T1, T2>(this T1 value, T2 other)
|
||||||
where T1 : IComparable<T2>
|
where T1 : IComparable<T2>
|
||||||
{
|
{
|
||||||
@ -249,11 +234,7 @@ public static class ComparableExtensions
|
|||||||
/// </example>
|
/// </example>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool LessThan<T1, T2>(this T1 value, T2 other)
|
public static bool LessThan<T1, T2>(this T1 value, T2 other)
|
||||||
where T1 : IComparable<T2>
|
where T1 : IComparable<T2>
|
||||||
{
|
{
|
||||||
@ -292,11 +273,7 @@ public static class ComparableExtensions
|
|||||||
/// </example>
|
/// </example>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool LessThanOrEqualTo<T1, T2>(this T1 value, T2 other)
|
public static bool LessThanOrEqualTo<T1, T2>(this T1 value, T2 other)
|
||||||
where T1 : IComparable<T2>
|
where T1 : IComparable<T2>
|
||||||
{
|
{
|
||||||
@ -334,11 +311,7 @@ public static class ComparableExtensions
|
|||||||
/// </example>
|
/// </example>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static T Max<T>(this T value, T other)
|
public static T Max<T>(this T value, T other)
|
||||||
where T : IComparable<T>
|
where T : IComparable<T>
|
||||||
{
|
{
|
||||||
@ -376,11 +349,7 @@ public static class ComparableExtensions
|
|||||||
/// </example>
|
/// </example>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static T Min<T>(this T value, T other)
|
public static T Min<T>(this T value, T other)
|
||||||
where T : IComparable<T>
|
where T : IComparable<T>
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Math;
|
namespace X10D.Math;
|
||||||
|
|
||||||
@ -15,11 +16,7 @@ public static class DecimalExtensions
|
|||||||
/// <param name="value">The number whose square root is to be found.</param>
|
/// <param name="value">The number whose square root is to be found.</param>
|
||||||
/// <returns>The square root of <paramref name="value" />.</returns>
|
/// <returns>The square root of <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Complex ComplexSqrt(this decimal value)
|
public static Complex ComplexSqrt(this decimal value)
|
||||||
{
|
{
|
||||||
return Complex.Sqrt((double)value);
|
return Complex.Sqrt((double)value);
|
||||||
@ -34,11 +31,7 @@ public static class DecimalExtensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsEven(this decimal value)
|
public static bool IsEven(this decimal value)
|
||||||
{
|
{
|
||||||
return value % 2.0m == 0.0m;
|
return value % 2.0m == 0.0m;
|
||||||
@ -53,11 +46,7 @@ public static class DecimalExtensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOdd(this decimal value)
|
public static bool IsOdd(this decimal value)
|
||||||
{
|
{
|
||||||
return !value.IsEven();
|
return !value.IsEven();
|
||||||
@ -69,11 +58,7 @@ public static class DecimalExtensions
|
|||||||
/// <param name="value">The value to round.</param>
|
/// <param name="value">The value to round.</param>
|
||||||
/// <returns><paramref name="value" /> rounded to the nearest whole number.</returns>
|
/// <returns><paramref name="value" /> rounded to the nearest whole number.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static decimal Round(this decimal value)
|
public static decimal Round(this decimal value)
|
||||||
{
|
{
|
||||||
return value.Round(1.0m);
|
return value.Round(1.0m);
|
||||||
@ -86,11 +71,7 @@ public static class DecimalExtensions
|
|||||||
/// <param name="nearest">The nearest multiple to which <paramref name="value" /> should be rounded.</param>
|
/// <param name="nearest">The nearest multiple to which <paramref name="value" /> should be rounded.</param>
|
||||||
/// <returns><paramref name="value" /> rounded to the nearest multiple of <paramref name="nearest" />.</returns>
|
/// <returns><paramref name="value" /> rounded to the nearest multiple of <paramref name="nearest" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static decimal Round(this decimal value, decimal nearest)
|
public static decimal Round(this decimal value, decimal nearest)
|
||||||
{
|
{
|
||||||
return System.Math.Round(value / nearest) * nearest;
|
return System.Math.Round(value / nearest) * nearest;
|
||||||
@ -103,11 +84,7 @@ public static class DecimalExtensions
|
|||||||
/// <returns>The saturated value.</returns>
|
/// <returns>The saturated value.</returns>
|
||||||
/// <remarks>This method clamps <paramref name="value" /> between 0 and 1.</remarks>
|
/// <remarks>This method clamps <paramref name="value" /> between 0 and 1.</remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static decimal Saturate(this decimal value)
|
public static decimal Saturate(this decimal value)
|
||||||
{
|
{
|
||||||
return System.Math.Clamp(value, 0.0m, 1.0m);
|
return System.Math.Clamp(value, 0.0m, 1.0m);
|
||||||
@ -141,11 +118,7 @@ public static class DecimalExtensions
|
|||||||
/// </list>
|
/// </list>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int Sign(this decimal value)
|
public static int Sign(this decimal value)
|
||||||
{
|
{
|
||||||
return System.Math.Sign(value);
|
return System.Math.Sign(value);
|
||||||
@ -180,11 +153,7 @@ public static class DecimalExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentException"><paramref name="value" /> is negative.</exception>
|
/// <exception cref="ArgumentException"><paramref name="value" /> is negative.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static decimal Sqrt(this decimal value)
|
public static decimal Sqrt(this decimal value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
@ -214,11 +183,7 @@ public static class DecimalExtensions
|
|||||||
/// <param name="high">The exclusive upper bound.</param>
|
/// <param name="high">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static decimal Wrap(this decimal value, decimal low, decimal high)
|
public static decimal Wrap(this decimal value, decimal low, decimal high)
|
||||||
{
|
{
|
||||||
decimal difference = high - low;
|
decimal difference = high - low;
|
||||||
@ -232,11 +197,7 @@ public static class DecimalExtensions
|
|||||||
/// <param name="length">The exclusive upper bound.</param>
|
/// <param name="length">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static decimal Wrap(this decimal value, decimal length)
|
public static decimal Wrap(this decimal value, decimal length)
|
||||||
{
|
{
|
||||||
return ((value % length) + length) % length;
|
return ((value % length) + length) % length;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Math;
|
namespace X10D.Math;
|
||||||
|
|
||||||
@ -20,11 +21,7 @@ public static class DoubleExtensions
|
|||||||
/// is equal to <see cref="double.NaN" />, less than -1, or greater than 1, <see cref="double.NaN" /> is returned.
|
/// is equal to <see cref="double.NaN" />, less than -1, or greater than 1, <see cref="double.NaN" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Acos(this double value)
|
public static double Acos(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Acos(value);
|
return System.Math.Acos(value);
|
||||||
@ -42,11 +39,7 @@ public static class DoubleExtensions
|
|||||||
/// <paramref name="value" /> is less than 1 or equal to <see cref="double.NaN" />, <see cref="double.NaN" /> is returned.
|
/// <paramref name="value" /> is less than 1 or equal to <see cref="double.NaN" />, <see cref="double.NaN" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Acosh(this double value)
|
public static double Acosh(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Acosh(value);
|
return System.Math.Acosh(value);
|
||||||
@ -64,11 +57,7 @@ public static class DoubleExtensions
|
|||||||
/// <see cref="double.NaN" /> is returned.
|
/// <see cref="double.NaN" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Asin(this double value)
|
public static double Asin(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Asin(value);
|
return System.Math.Asin(value);
|
||||||
@ -86,11 +75,7 @@ public static class DoubleExtensions
|
|||||||
/// <see cref="double.NaN" />, <see cref="double.NaN" /> is returned.
|
/// <see cref="double.NaN" />, <see cref="double.NaN" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Asinh(this double value)
|
public static double Asinh(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Asinh(value);
|
return System.Math.Asinh(value);
|
||||||
@ -107,11 +92,7 @@ public static class DoubleExtensions
|
|||||||
/// <paramref name="value" /> is equal to <see cref="double.NaN" />, <see cref="double.NaN" /> is returned.
|
/// <paramref name="value" /> is equal to <see cref="double.NaN" />, <see cref="double.NaN" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Atan(this double value)
|
public static double Atan(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Atan(value);
|
return System.Math.Atan(value);
|
||||||
@ -130,11 +111,7 @@ public static class DoubleExtensions
|
|||||||
/// <see cref="double.NaN" /> is returned.
|
/// <see cref="double.NaN" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Atanh(this double value)
|
public static double Atanh(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Atanh(value);
|
return System.Math.Atanh(value);
|
||||||
@ -146,11 +123,7 @@ public static class DoubleExtensions
|
|||||||
/// <param name="value">The number whose square root is to be found.</param>
|
/// <param name="value">The number whose square root is to be found.</param>
|
||||||
/// <returns>The square root of <paramref name="value" />.</returns>
|
/// <returns>The square root of <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Complex ComplexSqrt(this double value)
|
public static Complex ComplexSqrt(this double value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
@ -180,11 +153,7 @@ public static class DoubleExtensions
|
|||||||
/// <see cref="double.NaN" />.
|
/// <see cref="double.NaN" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Cos(this double value)
|
public static double Cos(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Cos(value);
|
return System.Math.Cos(value);
|
||||||
@ -201,11 +170,7 @@ public static class DoubleExtensions
|
|||||||
/// <see cref="double.NaN" />, <see cref="double.NaN" /> is returned.
|
/// <see cref="double.NaN" />, <see cref="double.NaN" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Cosh(this double value)
|
public static double Cosh(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Cosh(value);
|
return System.Math.Cosh(value);
|
||||||
@ -217,11 +182,7 @@ public static class DoubleExtensions
|
|||||||
/// <param name="value">The angle in degrees to convert.</param>
|
/// <param name="value">The angle in degrees to convert.</param>
|
||||||
/// <returns>The result of π * <paramref name="value" /> / 180.</returns>
|
/// <returns>The result of π * <paramref name="value" /> / 180.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double DegreesToRadians(this double value)
|
public static double DegreesToRadians(this double value)
|
||||||
{
|
{
|
||||||
return value * (System.Math.PI / 180.0);
|
return value * (System.Math.PI / 180.0);
|
||||||
@ -236,11 +197,7 @@ public static class DoubleExtensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsEven(this double value)
|
public static bool IsEven(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Abs(value % 2.0) < double.Epsilon;
|
return System.Math.Abs(value % 2.0) < double.Epsilon;
|
||||||
@ -255,11 +212,7 @@ public static class DoubleExtensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOdd(this double value)
|
public static bool IsOdd(this double value)
|
||||||
{
|
{
|
||||||
return !value.IsEven();
|
return !value.IsEven();
|
||||||
@ -271,11 +224,7 @@ public static class DoubleExtensions
|
|||||||
/// <param name="value">The angle in radians to convert.</param>
|
/// <param name="value">The angle in radians to convert.</param>
|
||||||
/// <returns>The result of π * <paramref name="value" /> / 180.</returns>
|
/// <returns>The result of π * <paramref name="value" /> / 180.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double RadiansToDegrees(this double value)
|
public static double RadiansToDegrees(this double value)
|
||||||
{
|
{
|
||||||
return value * (180.0 / System.Math.PI);
|
return value * (180.0 / System.Math.PI);
|
||||||
@ -287,11 +236,7 @@ public static class DoubleExtensions
|
|||||||
/// <param name="value">The value to round.</param>
|
/// <param name="value">The value to round.</param>
|
||||||
/// <returns><paramref name="value" /> rounded to the nearest whole number.</returns>
|
/// <returns><paramref name="value" /> rounded to the nearest whole number.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Round(this double value)
|
public static double Round(this double value)
|
||||||
{
|
{
|
||||||
return value.Round(1.0);
|
return value.Round(1.0);
|
||||||
@ -304,11 +249,7 @@ public static class DoubleExtensions
|
|||||||
/// <param name="nearest">The nearest multiple to which <paramref name="value" /> should be rounded.</param>
|
/// <param name="nearest">The nearest multiple to which <paramref name="value" /> should be rounded.</param>
|
||||||
/// <returns><paramref name="value" /> rounded to the nearest multiple of <paramref name="nearest" />.</returns>
|
/// <returns><paramref name="value" /> rounded to the nearest multiple of <paramref name="nearest" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Round(this double value, double nearest)
|
public static double Round(this double value, double nearest)
|
||||||
{
|
{
|
||||||
return System.Math.Round(value / nearest) * nearest;
|
return System.Math.Round(value / nearest) * nearest;
|
||||||
@ -321,11 +262,7 @@ public static class DoubleExtensions
|
|||||||
/// <returns>The saturated value.</returns>
|
/// <returns>The saturated value.</returns>
|
||||||
/// <remarks>This method clamps <paramref name="value" /> between 0 and 1.</remarks>
|
/// <remarks>This method clamps <paramref name="value" /> between 0 and 1.</remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Saturate(this double value)
|
public static double Saturate(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Clamp(value, 0.0, 1.0);
|
return System.Math.Clamp(value, 0.0, 1.0);
|
||||||
@ -341,11 +278,7 @@ public static class DoubleExtensions
|
|||||||
/// <see cref="double.NaN" />.
|
/// <see cref="double.NaN" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Sin(this double value)
|
public static double Sin(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Sin(value);
|
return System.Math.Sin(value);
|
||||||
@ -361,11 +294,7 @@ public static class DoubleExtensions
|
|||||||
/// <see cref="double.NaN" />.
|
/// <see cref="double.NaN" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Sinh(this double value)
|
public static double Sinh(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Sinh(value);
|
return System.Math.Sinh(value);
|
||||||
@ -400,11 +329,7 @@ public static class DoubleExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArithmeticException"><paramref name="value" /> is equal to <see cref="double.NaN" />.</exception>
|
/// <exception cref="ArithmeticException"><paramref name="value" /> is equal to <see cref="double.NaN" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int Sign(this double value)
|
public static int Sign(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Sign(value);
|
return System.Math.Sign(value);
|
||||||
@ -440,11 +365,7 @@ public static class DoubleExtensions
|
|||||||
/// <author>SLenik https://stackoverflow.com/a/6755197/1467293</author>
|
/// <author>SLenik https://stackoverflow.com/a/6755197/1467293</author>
|
||||||
/// <license>CC BY-SA 3.0</license>
|
/// <license>CC BY-SA 3.0</license>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Sqrt(this double value)
|
public static double Sqrt(this double value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
@ -478,11 +399,7 @@ public static class DoubleExtensions
|
|||||||
/// <see cref="double.NaN" />.
|
/// <see cref="double.NaN" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Tan(this double value)
|
public static double Tan(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Tan(value);
|
return System.Math.Tan(value);
|
||||||
@ -499,11 +416,7 @@ public static class DoubleExtensions
|
|||||||
/// <see cref="double.NaN" />, this method returns <see cref="double.NaN" />.
|
/// <see cref="double.NaN" />, this method returns <see cref="double.NaN" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Tanh(this double value)
|
public static double Tanh(this double value)
|
||||||
{
|
{
|
||||||
return System.Math.Tanh(value);
|
return System.Math.Tanh(value);
|
||||||
@ -517,11 +430,7 @@ public static class DoubleExtensions
|
|||||||
/// <param name="high">The exclusive upper bound.</param>
|
/// <param name="high">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Wrap(this double value, double low, double high)
|
public static double Wrap(this double value, double low, double high)
|
||||||
{
|
{
|
||||||
double difference = high - low;
|
double difference = high - low;
|
||||||
@ -535,11 +444,7 @@ public static class DoubleExtensions
|
|||||||
/// <param name="length">The exclusive upper bound.</param>
|
/// <param name="length">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Wrap(this double value, double length)
|
public static double Wrap(this double value, double length)
|
||||||
{
|
{
|
||||||
return ((value % length) + length) % length;
|
return ((value % length) + length) % length;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Math;
|
namespace X10D.Math;
|
||||||
|
|
||||||
@ -18,11 +19,7 @@ public static class Int16Extensions
|
|||||||
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static short DigitalRoot(this short value)
|
public static short DigitalRoot(this short value)
|
||||||
{
|
{
|
||||||
short root = System.Math.Abs(value).Mod(9);
|
short root = System.Math.Abs(value).Mod(9);
|
||||||
@ -36,11 +33,7 @@ public static class Int16Extensions
|
|||||||
/// <returns>The factorial of <paramref name="value" />.</returns>
|
/// <returns>The factorial of <paramref name="value" />.</returns>
|
||||||
/// <exception cref="ArithmeticException"><paramref name="value" /> is less than 0.</exception>
|
/// <exception cref="ArithmeticException"><paramref name="value" /> is less than 0.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long Factorial(this short value)
|
public static long Factorial(this short value)
|
||||||
{
|
{
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
@ -69,11 +62,7 @@ public static class Int16Extensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static short GreatestCommonFactor(this short value, short other)
|
public static short GreatestCommonFactor(this short value, short other)
|
||||||
{
|
{
|
||||||
return (short)((long)value).GreatestCommonFactor(other);
|
return (short)((long)value).GreatestCommonFactor(other);
|
||||||
@ -88,11 +77,7 @@ public static class Int16Extensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsEven(this short value)
|
public static bool IsEven(this short value)
|
||||||
{
|
{
|
||||||
return (value & 1) == 0;
|
return (value & 1) == 0;
|
||||||
@ -107,11 +92,7 @@ public static class Int16Extensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOdd(this short value)
|
public static bool IsOdd(this short value)
|
||||||
{
|
{
|
||||||
return !value.IsEven();
|
return !value.IsEven();
|
||||||
@ -125,11 +106,7 @@ public static class Int16Extensions
|
|||||||
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsPrime(this short value)
|
public static bool IsPrime(this short value)
|
||||||
{
|
{
|
||||||
return ((long)value).IsPrime();
|
return ((long)value).IsPrime();
|
||||||
@ -142,11 +119,7 @@ public static class Int16Extensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static short LowestCommonMultiple(this short value, short other)
|
public static short LowestCommonMultiple(this short value, short other)
|
||||||
{
|
{
|
||||||
return (short)((long)value).LowestCommonMultiple(other);
|
return (short)((long)value).LowestCommonMultiple(other);
|
||||||
@ -167,11 +140,7 @@ public static class Int16Extensions
|
|||||||
/// <author>ShreevatsaR, https://stackoverflow.com/a/1082938/1467293</author>
|
/// <author>ShreevatsaR, https://stackoverflow.com/a/1082938/1467293</author>
|
||||||
/// <license>CC-BY-SA 2.5</license>
|
/// <license>CC-BY-SA 2.5</license>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static short Mod(this short dividend, short divisor)
|
public static short Mod(this short dividend, short divisor)
|
||||||
{
|
{
|
||||||
int r = dividend % divisor;
|
int r = dividend % divisor;
|
||||||
@ -187,11 +156,7 @@ public static class Int16Extensions
|
|||||||
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int MultiplicativePersistence(this short value)
|
public static int MultiplicativePersistence(this short value)
|
||||||
{
|
{
|
||||||
return ((long)value).MultiplicativePersistence();
|
return ((long)value).MultiplicativePersistence();
|
||||||
@ -225,11 +190,7 @@ public static class Int16Extensions
|
|||||||
/// </list>
|
/// </list>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int Sign(this short value)
|
public static int Sign(this short value)
|
||||||
{
|
{
|
||||||
return System.Math.Sign(value);
|
return System.Math.Sign(value);
|
||||||
@ -243,11 +204,7 @@ public static class Int16Extensions
|
|||||||
/// <param name="high">The exclusive upper bound.</param>
|
/// <param name="high">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static short Wrap(this short value, short low, short high)
|
public static short Wrap(this short value, short low, short high)
|
||||||
{
|
{
|
||||||
return (short)((long)value).Wrap(low, high);
|
return (short)((long)value).Wrap(low, high);
|
||||||
@ -260,11 +217,7 @@ public static class Int16Extensions
|
|||||||
/// <param name="length">The exclusive upper bound.</param>
|
/// <param name="length">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static short Wrap(this short value, short length)
|
public static short Wrap(this short value, short length)
|
||||||
{
|
{
|
||||||
return (short)((long)value).Wrap(length);
|
return (short)((long)value).Wrap(length);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Math;
|
namespace X10D.Math;
|
||||||
|
|
||||||
@ -18,11 +19,7 @@ public static class Int32Extensions
|
|||||||
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int DigitalRoot(this int value)
|
public static int DigitalRoot(this int value)
|
||||||
{
|
{
|
||||||
int root = System.Math.Abs(value).Mod(9);
|
int root = System.Math.Abs(value).Mod(9);
|
||||||
@ -36,11 +33,7 @@ public static class Int32Extensions
|
|||||||
/// <returns>The factorial of <paramref name="value" />.</returns>
|
/// <returns>The factorial of <paramref name="value" />.</returns>
|
||||||
/// <exception cref="ArithmeticException"><paramref name="value" /> is less than 0.</exception>
|
/// <exception cref="ArithmeticException"><paramref name="value" /> is less than 0.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long Factorial(this int value)
|
public static long Factorial(this int value)
|
||||||
{
|
{
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
@ -69,11 +62,7 @@ public static class Int32Extensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int GreatestCommonFactor(this int value, int other)
|
public static int GreatestCommonFactor(this int value, int other)
|
||||||
{
|
{
|
||||||
return (int)((long)value).GreatestCommonFactor(other);
|
return (int)((long)value).GreatestCommonFactor(other);
|
||||||
@ -88,11 +77,7 @@ public static class Int32Extensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsEven(this int value)
|
public static bool IsEven(this int value)
|
||||||
{
|
{
|
||||||
return (value & 1) == 0;
|
return (value & 1) == 0;
|
||||||
@ -107,11 +92,7 @@ public static class Int32Extensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOdd(this int value)
|
public static bool IsOdd(this int value)
|
||||||
{
|
{
|
||||||
return !value.IsEven();
|
return !value.IsEven();
|
||||||
@ -125,11 +106,7 @@ public static class Int32Extensions
|
|||||||
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsPrime(this int value)
|
public static bool IsPrime(this int value)
|
||||||
{
|
{
|
||||||
return ((long)value).IsPrime();
|
return ((long)value).IsPrime();
|
||||||
@ -142,11 +119,7 @@ public static class Int32Extensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int LowestCommonMultiple(this int value, int other)
|
public static int LowestCommonMultiple(this int value, int other)
|
||||||
{
|
{
|
||||||
return (int)((long)value).LowestCommonMultiple(other);
|
return (int)((long)value).LowestCommonMultiple(other);
|
||||||
@ -167,11 +140,7 @@ public static class Int32Extensions
|
|||||||
/// <author>ShreevatsaR, https://stackoverflow.com/a/1082938/1467293</author>
|
/// <author>ShreevatsaR, https://stackoverflow.com/a/1082938/1467293</author>
|
||||||
/// <license>CC-BY-SA 2.5</license>
|
/// <license>CC-BY-SA 2.5</license>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int Mod(this int dividend, int divisor)
|
public static int Mod(this int dividend, int divisor)
|
||||||
{
|
{
|
||||||
int r = dividend % divisor;
|
int r = dividend % divisor;
|
||||||
@ -187,11 +156,7 @@ public static class Int32Extensions
|
|||||||
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int MultiplicativePersistence(this int value)
|
public static int MultiplicativePersistence(this int value)
|
||||||
{
|
{
|
||||||
return ((long)value).MultiplicativePersistence();
|
return ((long)value).MultiplicativePersistence();
|
||||||
@ -225,11 +190,7 @@ public static class Int32Extensions
|
|||||||
/// </list>
|
/// </list>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int Sign(this int value)
|
public static int Sign(this int value)
|
||||||
{
|
{
|
||||||
return System.Math.Sign(value);
|
return System.Math.Sign(value);
|
||||||
@ -243,11 +204,7 @@ public static class Int32Extensions
|
|||||||
/// <param name="high">The exclusive upper bound.</param>
|
/// <param name="high">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int Wrap(this int value, int low, int high)
|
public static int Wrap(this int value, int low, int high)
|
||||||
{
|
{
|
||||||
return (int)((long)value).Wrap(low, high);
|
return (int)((long)value).Wrap(low, high);
|
||||||
@ -260,11 +217,7 @@ public static class Int32Extensions
|
|||||||
/// <param name="length">The exclusive upper bound.</param>
|
/// <param name="length">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int Wrap(this int value, int length)
|
public static int Wrap(this int value, int length)
|
||||||
{
|
{
|
||||||
return (int)((long)value).Wrap(length);
|
return (int)((long)value).Wrap(length);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Math;
|
namespace X10D.Math;
|
||||||
|
|
||||||
@ -18,11 +19,7 @@ public static class Int64Extensions
|
|||||||
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long DigitalRoot(this long value)
|
public static long DigitalRoot(this long value)
|
||||||
{
|
{
|
||||||
long root = System.Math.Abs(value).Mod(9L);
|
long root = System.Math.Abs(value).Mod(9L);
|
||||||
@ -36,11 +33,7 @@ public static class Int64Extensions
|
|||||||
/// <returns>The factorial of <paramref name="value" />.</returns>
|
/// <returns>The factorial of <paramref name="value" />.</returns>
|
||||||
/// <exception cref="ArithmeticException"><paramref name="value" /> is less than 0.</exception>
|
/// <exception cref="ArithmeticException"><paramref name="value" /> is less than 0.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long Factorial(this long value)
|
public static long Factorial(this long value)
|
||||||
{
|
{
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
@ -69,11 +62,7 @@ public static class Int64Extensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long GreatestCommonFactor(this long value, long other)
|
public static long GreatestCommonFactor(this long value, long other)
|
||||||
{
|
{
|
||||||
while (other != 0)
|
while (other != 0)
|
||||||
@ -93,11 +82,7 @@ public static class Int64Extensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsEven(this long value)
|
public static bool IsEven(this long value)
|
||||||
{
|
{
|
||||||
return (value & 1) == 0;
|
return (value & 1) == 0;
|
||||||
@ -112,11 +97,7 @@ public static class Int64Extensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOdd(this long value)
|
public static bool IsOdd(this long value)
|
||||||
{
|
{
|
||||||
return !value.IsEven();
|
return !value.IsEven();
|
||||||
@ -130,11 +111,7 @@ public static class Int64Extensions
|
|||||||
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsPrime(this long value)
|
public static bool IsPrime(this long value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
@ -166,11 +143,7 @@ public static class Int64Extensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long LowestCommonMultiple(this long value, long other)
|
public static long LowestCommonMultiple(this long value, long other)
|
||||||
{
|
{
|
||||||
if (value == 0 || other == 0)
|
if (value == 0 || other == 0)
|
||||||
@ -206,11 +179,7 @@ public static class Int64Extensions
|
|||||||
/// <author>ShreevatsaR, https://stackoverflow.com/a/1082938/1467293</author>
|
/// <author>ShreevatsaR, https://stackoverflow.com/a/1082938/1467293</author>
|
||||||
/// <license>CC-BY-SA 2.5</license>
|
/// <license>CC-BY-SA 2.5</license>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long Mod(this long dividend, long divisor)
|
public static long Mod(this long dividend, long divisor)
|
||||||
{
|
{
|
||||||
long r = dividend % divisor;
|
long r = dividend % divisor;
|
||||||
@ -226,11 +195,7 @@ public static class Int64Extensions
|
|||||||
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int MultiplicativePersistence(this long value)
|
public static int MultiplicativePersistence(this long value)
|
||||||
{
|
{
|
||||||
var persistence = 0;
|
var persistence = 0;
|
||||||
@ -295,11 +260,7 @@ public static class Int64Extensions
|
|||||||
/// </list>
|
/// </list>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int Sign(this long value)
|
public static int Sign(this long value)
|
||||||
{
|
{
|
||||||
return System.Math.Sign(value);
|
return System.Math.Sign(value);
|
||||||
@ -313,11 +274,7 @@ public static class Int64Extensions
|
|||||||
/// <param name="high">The exclusive upper bound.</param>
|
/// <param name="high">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long Wrap(this long value, long low, long high)
|
public static long Wrap(this long value, long low, long high)
|
||||||
{
|
{
|
||||||
long difference = high - low;
|
long difference = high - low;
|
||||||
@ -331,11 +288,7 @@ public static class Int64Extensions
|
|||||||
/// <param name="length">The exclusive upper bound.</param>
|
/// <param name="length">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long Wrap(this long value, long length)
|
public static long Wrap(this long value, long length)
|
||||||
{
|
{
|
||||||
return ((value % length) + length) % length;
|
return ((value % length) + length) % length;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Math;
|
namespace X10D.Math;
|
||||||
|
|
||||||
@ -69,11 +70,7 @@ public static class MathUtility
|
|||||||
/// <param name="value">The gamma-encoded value to convert. Expected range is [0, 1].</param>
|
/// <param name="value">The gamma-encoded value to convert. Expected range is [0, 1].</param>
|
||||||
/// <returns>The linear value.</returns>
|
/// <returns>The linear value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float GammaToLinear(float value)
|
public static float GammaToLinear(float value)
|
||||||
{
|
{
|
||||||
return GammaToLinear(value, DefaultGammaF);
|
return GammaToLinear(value, DefaultGammaF);
|
||||||
@ -86,11 +83,7 @@ public static class MathUtility
|
|||||||
/// <param name="gamma">The gamma value to use for decoding.</param>
|
/// <param name="gamma">The gamma value to use for decoding.</param>
|
||||||
/// <returns>The linear value.</returns>
|
/// <returns>The linear value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float GammaToLinear(float value, float gamma)
|
public static float GammaToLinear(float value, float gamma)
|
||||||
{
|
{
|
||||||
return MathF.Pow(value, 1.0f / gamma);
|
return MathF.Pow(value, 1.0f / gamma);
|
||||||
@ -102,11 +95,7 @@ public static class MathUtility
|
|||||||
/// <param name="value">The gamma-encoded value to convert. Expected range is [0, 1].</param>
|
/// <param name="value">The gamma-encoded value to convert. Expected range is [0, 1].</param>
|
||||||
/// <returns>The linear value.</returns>
|
/// <returns>The linear value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double GammaToLinear(double value)
|
public static double GammaToLinear(double value)
|
||||||
{
|
{
|
||||||
return GammaToLinear(value, DefaultGamma);
|
return GammaToLinear(value, DefaultGamma);
|
||||||
@ -119,11 +108,7 @@ public static class MathUtility
|
|||||||
/// <param name="gamma">The gamma value to use for decoding.</param>
|
/// <param name="gamma">The gamma value to use for decoding.</param>
|
||||||
/// <returns>The linear value.</returns>
|
/// <returns>The linear value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double GammaToLinear(double value, double gamma)
|
public static double GammaToLinear(double value, double gamma)
|
||||||
{
|
{
|
||||||
return System.Math.Pow(value, 1.0 / gamma);
|
return System.Math.Pow(value, 1.0 / gamma);
|
||||||
@ -138,11 +123,7 @@ public static class MathUtility
|
|||||||
/// <param name="end">The end of the range.</param>
|
/// <param name="end">The end of the range.</param>
|
||||||
/// <returns>A value determined by <c>(alpha - start) / (end - start)</c>.</returns>
|
/// <returns>A value determined by <c>(alpha - start) / (end - start)</c>.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float InverseLerp(float alpha, float start, float end)
|
public static float InverseLerp(float alpha, float start, float end)
|
||||||
{
|
{
|
||||||
if (MathF.Abs(start - end) < float.Epsilon)
|
if (MathF.Abs(start - end) < float.Epsilon)
|
||||||
@ -162,11 +143,7 @@ public static class MathUtility
|
|||||||
/// <param name="end">The end of the range.</param>
|
/// <param name="end">The end of the range.</param>
|
||||||
/// <returns>A value determined by <c>(alpha - start) / (end - start)</c>.</returns>
|
/// <returns>A value determined by <c>(alpha - start) / (end - start)</c>.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double InverseLerp(double alpha, double start, double end)
|
public static double InverseLerp(double alpha, double start, double end)
|
||||||
{
|
{
|
||||||
if (System.Math.Abs(start - end) < double.Epsilon)
|
if (System.Math.Abs(start - end) < double.Epsilon)
|
||||||
@ -187,11 +164,7 @@ public static class MathUtility
|
|||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Lerp(float value, float target, float alpha)
|
public static float Lerp(float value, float target, float alpha)
|
||||||
{
|
{
|
||||||
// rookie mistake: a + t * (b - a)
|
// rookie mistake: a + t * (b - a)
|
||||||
@ -209,11 +182,7 @@ public static class MathUtility
|
|||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double Lerp(double value, double target, double alpha)
|
public static double Lerp(double value, double target, double alpha)
|
||||||
{
|
{
|
||||||
// rookie mistake: a + t * (b - a)
|
// rookie mistake: a + t * (b - a)
|
||||||
@ -227,11 +196,7 @@ public static class MathUtility
|
|||||||
/// <param name="value">The linear value to convert. Expected range is [0, 1].</param>
|
/// <param name="value">The linear value to convert. Expected range is [0, 1].</param>
|
||||||
/// <returns>The gamma-encoded value.</returns>
|
/// <returns>The gamma-encoded value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float LinearToGamma(float value)
|
public static float LinearToGamma(float value)
|
||||||
{
|
{
|
||||||
return LinearToGamma(value, DefaultGammaF);
|
return LinearToGamma(value, DefaultGammaF);
|
||||||
@ -244,11 +209,7 @@ public static class MathUtility
|
|||||||
/// <param name="gamma">The gamma value to use for encoding.</param>
|
/// <param name="gamma">The gamma value to use for encoding.</param>
|
||||||
/// <returns>The gamma-encoded value.</returns>
|
/// <returns>The gamma-encoded value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float LinearToGamma(float value, float gamma)
|
public static float LinearToGamma(float value, float gamma)
|
||||||
{
|
{
|
||||||
return MathF.Pow(value, 1.0f / gamma);
|
return MathF.Pow(value, 1.0f / gamma);
|
||||||
@ -260,11 +221,7 @@ public static class MathUtility
|
|||||||
/// <param name="value">The linear value to convert. Expected range is [0, 1].</param>
|
/// <param name="value">The linear value to convert. Expected range is [0, 1].</param>
|
||||||
/// <returns>The gamma-encoded value.</returns>
|
/// <returns>The gamma-encoded value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double LinearToGamma(double value)
|
public static double LinearToGamma(double value)
|
||||||
{
|
{
|
||||||
return LinearToGamma(value, DefaultGamma);
|
return LinearToGamma(value, DefaultGamma);
|
||||||
@ -277,11 +234,7 @@ public static class MathUtility
|
|||||||
/// <param name="gamma">The gamma value to use for encoding.</param>
|
/// <param name="gamma">The gamma value to use for encoding.</param>
|
||||||
/// <returns>The gamma-encoded value.</returns>
|
/// <returns>The gamma-encoded value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double LinearToGamma(double value, double gamma)
|
public static double LinearToGamma(double value, double gamma)
|
||||||
{
|
{
|
||||||
return System.Math.Pow(value, 1.0 / gamma);
|
return System.Math.Pow(value, 1.0 / gamma);
|
||||||
@ -365,11 +318,7 @@ public static class MathUtility
|
|||||||
/// <param name="newMax">The new maximum value.</param>
|
/// <param name="newMax">The new maximum value.</param>
|
||||||
/// <returns>The scaled value.</returns>
|
/// <returns>The scaled value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float ScaleRange(float value, float oldMin, float oldMax, float newMin, float newMax)
|
public static float ScaleRange(float value, float oldMin, float oldMax, float newMin, float newMax)
|
||||||
{
|
{
|
||||||
float oldRange = oldMax - oldMin;
|
float oldRange = oldMax - oldMin;
|
||||||
@ -388,11 +337,7 @@ public static class MathUtility
|
|||||||
/// <param name="newMax">The new maximum value.</param>
|
/// <param name="newMax">The new maximum value.</param>
|
||||||
/// <returns>The scaled value.</returns>
|
/// <returns>The scaled value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static double ScaleRange(double value, double oldMin, double oldMax, double newMin, double newMax)
|
public static double ScaleRange(double value, double oldMin, double oldMax, double newMin, double newMax)
|
||||||
{
|
{
|
||||||
double oldRange = oldMax - oldMin;
|
double oldRange = oldMax - oldMin;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Math;
|
namespace X10D.Math;
|
||||||
|
|
||||||
@ -19,11 +20,7 @@ public static class SByteExtensions
|
|||||||
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static sbyte DigitalRoot(this sbyte value)
|
public static sbyte DigitalRoot(this sbyte value)
|
||||||
{
|
{
|
||||||
int root = System.Math.Abs(value).Mod(9);
|
int root = System.Math.Abs(value).Mod(9);
|
||||||
@ -37,11 +34,7 @@ public static class SByteExtensions
|
|||||||
/// <returns>The factorial of <paramref name="value" />.</returns>
|
/// <returns>The factorial of <paramref name="value" />.</returns>
|
||||||
/// <exception cref="ArithmeticException"><paramref name="value" /> is less than 0.</exception>
|
/// <exception cref="ArithmeticException"><paramref name="value" /> is less than 0.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long Factorial(this sbyte value)
|
public static long Factorial(this sbyte value)
|
||||||
{
|
{
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
@ -70,11 +63,7 @@ public static class SByteExtensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static sbyte GreatestCommonFactor(this sbyte value, sbyte other)
|
public static sbyte GreatestCommonFactor(this sbyte value, sbyte other)
|
||||||
{
|
{
|
||||||
return (sbyte)((long)value).GreatestCommonFactor(other);
|
return (sbyte)((long)value).GreatestCommonFactor(other);
|
||||||
@ -89,11 +78,7 @@ public static class SByteExtensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsEven(this sbyte value)
|
public static bool IsEven(this sbyte value)
|
||||||
{
|
{
|
||||||
return (value & 1) == 0;
|
return (value & 1) == 0;
|
||||||
@ -108,11 +93,7 @@ public static class SByteExtensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOdd(this sbyte value)
|
public static bool IsOdd(this sbyte value)
|
||||||
{
|
{
|
||||||
return !value.IsEven();
|
return !value.IsEven();
|
||||||
@ -126,11 +107,7 @@ public static class SByteExtensions
|
|||||||
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsPrime(this sbyte value)
|
public static bool IsPrime(this sbyte value)
|
||||||
{
|
{
|
||||||
return ((long)value).IsPrime();
|
return ((long)value).IsPrime();
|
||||||
@ -143,11 +120,7 @@ public static class SByteExtensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static sbyte LowestCommonMultiple(this sbyte value, sbyte other)
|
public static sbyte LowestCommonMultiple(this sbyte value, sbyte other)
|
||||||
{
|
{
|
||||||
return (sbyte)((long)value).LowestCommonMultiple(other);
|
return (sbyte)((long)value).LowestCommonMultiple(other);
|
||||||
@ -168,11 +141,7 @@ public static class SByteExtensions
|
|||||||
/// <author>ShreevatsaR, https://stackoverflow.com/a/1082938/1467293</author>
|
/// <author>ShreevatsaR, https://stackoverflow.com/a/1082938/1467293</author>
|
||||||
/// <license>CC-BY-SA 2.5</license>
|
/// <license>CC-BY-SA 2.5</license>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static sbyte Mod(this sbyte dividend, sbyte divisor)
|
public static sbyte Mod(this sbyte dividend, sbyte divisor)
|
||||||
{
|
{
|
||||||
int r = dividend % divisor;
|
int r = dividend % divisor;
|
||||||
@ -188,11 +157,7 @@ public static class SByteExtensions
|
|||||||
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int MultiplicativePersistence(this sbyte value)
|
public static int MultiplicativePersistence(this sbyte value)
|
||||||
{
|
{
|
||||||
return ((long)value).MultiplicativePersistence();
|
return ((long)value).MultiplicativePersistence();
|
||||||
@ -226,11 +191,7 @@ public static class SByteExtensions
|
|||||||
/// </list>
|
/// </list>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int Sign(this sbyte value)
|
public static int Sign(this sbyte value)
|
||||||
{
|
{
|
||||||
return System.Math.Sign(value);
|
return System.Math.Sign(value);
|
||||||
@ -244,11 +205,7 @@ public static class SByteExtensions
|
|||||||
/// <param name="high">The exclusive upper bound.</param>
|
/// <param name="high">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static sbyte Wrap(this sbyte value, sbyte low, sbyte high)
|
public static sbyte Wrap(this sbyte value, sbyte low, sbyte high)
|
||||||
{
|
{
|
||||||
return (sbyte)((long)value).Wrap(low, high);
|
return (sbyte)((long)value).Wrap(low, high);
|
||||||
@ -261,11 +218,7 @@ public static class SByteExtensions
|
|||||||
/// <param name="length">The exclusive upper bound.</param>
|
/// <param name="length">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static sbyte Wrap(this sbyte value, sbyte length)
|
public static sbyte Wrap(this sbyte value, sbyte length)
|
||||||
{
|
{
|
||||||
return (sbyte)((long)value).Wrap(length);
|
return (sbyte)((long)value).Wrap(length);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Math;
|
namespace X10D.Math;
|
||||||
|
|
||||||
@ -20,11 +21,7 @@ public static class SingleExtensions
|
|||||||
/// is equal to <see cref="float.NaN" />, less than -1, or greater than 1, <see cref="float.NaN" /> is returned.
|
/// is equal to <see cref="float.NaN" />, less than -1, or greater than 1, <see cref="float.NaN" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Acos(this float value)
|
public static float Acos(this float value)
|
||||||
{
|
{
|
||||||
return MathF.Acos(value);
|
return MathF.Acos(value);
|
||||||
@ -42,11 +39,7 @@ public static class SingleExtensions
|
|||||||
/// <paramref name="value" /> is less than 1 or equal to <see cref="float.NaN" />, <see cref="float.NaN" /> is returned.
|
/// <paramref name="value" /> is less than 1 or equal to <see cref="float.NaN" />, <see cref="float.NaN" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Acosh(this float value)
|
public static float Acosh(this float value)
|
||||||
{
|
{
|
||||||
return MathF.Acosh(value);
|
return MathF.Acosh(value);
|
||||||
@ -64,11 +57,7 @@ public static class SingleExtensions
|
|||||||
/// <see cref="float.NaN" /> is returned.
|
/// <see cref="float.NaN" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Asin(this float value)
|
public static float Asin(this float value)
|
||||||
{
|
{
|
||||||
return MathF.Asin(value);
|
return MathF.Asin(value);
|
||||||
@ -86,11 +75,7 @@ public static class SingleExtensions
|
|||||||
/// <see cref="float.NaN" />, <see cref="float.NaN" /> is returned.
|
/// <see cref="float.NaN" />, <see cref="float.NaN" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Asinh(this float value)
|
public static float Asinh(this float value)
|
||||||
{
|
{
|
||||||
return MathF.Asinh(value);
|
return MathF.Asinh(value);
|
||||||
@ -107,11 +92,7 @@ public static class SingleExtensions
|
|||||||
/// <paramref name="value" /> is equal to <see cref="float.NaN" />, <see cref="float.NaN" /> is returned.
|
/// <paramref name="value" /> is equal to <see cref="float.NaN" />, <see cref="float.NaN" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Atan(this float value)
|
public static float Atan(this float value)
|
||||||
{
|
{
|
||||||
return MathF.Atan(value);
|
return MathF.Atan(value);
|
||||||
@ -130,11 +111,7 @@ public static class SingleExtensions
|
|||||||
/// <see cref="float.NaN" /> is returned.
|
/// <see cref="float.NaN" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Atanh(this float value)
|
public static float Atanh(this float value)
|
||||||
{
|
{
|
||||||
return MathF.Atanh(value);
|
return MathF.Atanh(value);
|
||||||
@ -146,11 +123,7 @@ public static class SingleExtensions
|
|||||||
/// <param name="value">The number whose square root is to be found.</param>
|
/// <param name="value">The number whose square root is to be found.</param>
|
||||||
/// <returns>The square root of <paramref name="value" />.</returns>
|
/// <returns>The square root of <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Complex ComplexSqrt(this float value)
|
public static Complex ComplexSqrt(this float value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
@ -180,11 +153,7 @@ public static class SingleExtensions
|
|||||||
/// <see cref="float.NaN" />.
|
/// <see cref="float.NaN" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Cos(this float value)
|
public static float Cos(this float value)
|
||||||
{
|
{
|
||||||
return MathF.Cos(value);
|
return MathF.Cos(value);
|
||||||
@ -201,11 +170,7 @@ public static class SingleExtensions
|
|||||||
/// <see cref="float.NaN" />, <see cref="double.NaN" /> is returned.
|
/// <see cref="float.NaN" />, <see cref="double.NaN" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Cosh(this float value)
|
public static float Cosh(this float value)
|
||||||
{
|
{
|
||||||
return MathF.Cosh(value);
|
return MathF.Cosh(value);
|
||||||
@ -217,11 +182,7 @@ public static class SingleExtensions
|
|||||||
/// <param name="value">The angle in degrees to convert.</param>
|
/// <param name="value">The angle in degrees to convert.</param>
|
||||||
/// <returns>The result of π * <paramref name="value" /> / 180.</returns>
|
/// <returns>The result of π * <paramref name="value" /> / 180.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float DegreesToRadians(this float value)
|
public static float DegreesToRadians(this float value)
|
||||||
{
|
{
|
||||||
return value * (MathF.PI / 180.0f);
|
return value * (MathF.PI / 180.0f);
|
||||||
@ -236,11 +197,7 @@ public static class SingleExtensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsEven(this float value)
|
public static bool IsEven(this float value)
|
||||||
{
|
{
|
||||||
return value % 2 == 0;
|
return value % 2 == 0;
|
||||||
@ -255,11 +212,7 @@ public static class SingleExtensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOdd(this float value)
|
public static bool IsOdd(this float value)
|
||||||
{
|
{
|
||||||
return !value.IsEven();
|
return !value.IsEven();
|
||||||
@ -271,11 +224,7 @@ public static class SingleExtensions
|
|||||||
/// <param name="value">The angle in radians to convert.</param>
|
/// <param name="value">The angle in radians to convert.</param>
|
||||||
/// <returns>The result of π * <paramref name="value" /> / 180.</returns>
|
/// <returns>The result of π * <paramref name="value" /> / 180.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float RadiansToDegrees(this float value)
|
public static float RadiansToDegrees(this float value)
|
||||||
{
|
{
|
||||||
return value * (180.0f / MathF.PI);
|
return value * (180.0f / MathF.PI);
|
||||||
@ -287,11 +236,7 @@ public static class SingleExtensions
|
|||||||
/// <param name="value">The value to round.</param>
|
/// <param name="value">The value to round.</param>
|
||||||
/// <returns><paramref name="value" /> rounded to the nearest whole number.</returns>
|
/// <returns><paramref name="value" /> rounded to the nearest whole number.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Round(this float value)
|
public static float Round(this float value)
|
||||||
{
|
{
|
||||||
return value.Round(1.0f);
|
return value.Round(1.0f);
|
||||||
@ -304,11 +249,7 @@ public static class SingleExtensions
|
|||||||
/// <param name="nearest">The nearest multiple to which <paramref name="value" /> should be rounded.</param>
|
/// <param name="nearest">The nearest multiple to which <paramref name="value" /> should be rounded.</param>
|
||||||
/// <returns><paramref name="value" /> rounded to the nearest multiple of <paramref name="nearest" />.</returns>
|
/// <returns><paramref name="value" /> rounded to the nearest multiple of <paramref name="nearest" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Round(this float value, float nearest)
|
public static float Round(this float value, float nearest)
|
||||||
{
|
{
|
||||||
return MathF.Round(value / nearest) * nearest;
|
return MathF.Round(value / nearest) * nearest;
|
||||||
@ -321,11 +262,7 @@ public static class SingleExtensions
|
|||||||
/// <returns>The saturated value.</returns>
|
/// <returns>The saturated value.</returns>
|
||||||
/// <remarks>This method clamps <paramref name="value" /> between 0 and 1.</remarks>
|
/// <remarks>This method clamps <paramref name="value" /> between 0 and 1.</remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Saturate(this float value)
|
public static float Saturate(this float value)
|
||||||
{
|
{
|
||||||
return System.Math.Clamp(value, 0.0f, 1.0f);
|
return System.Math.Clamp(value, 0.0f, 1.0f);
|
||||||
@ -359,11 +296,7 @@ public static class SingleExtensions
|
|||||||
/// </list>
|
/// </list>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int Sign(this float value)
|
public static int Sign(this float value)
|
||||||
{
|
{
|
||||||
return MathF.Sign(value);
|
return MathF.Sign(value);
|
||||||
@ -399,11 +332,7 @@ public static class SingleExtensions
|
|||||||
/// <author>SLenik https://stackoverflow.com/a/6755197/1467293</author>
|
/// <author>SLenik https://stackoverflow.com/a/6755197/1467293</author>
|
||||||
/// <license>CC BY-SA 3.0</license>
|
/// <license>CC BY-SA 3.0</license>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Sqrt(this float value)
|
public static float Sqrt(this float value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
@ -437,11 +366,7 @@ public static class SingleExtensions
|
|||||||
/// <see cref="double.NaN" />.
|
/// <see cref="double.NaN" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Sin(this float value)
|
public static float Sin(this float value)
|
||||||
{
|
{
|
||||||
return MathF.Sin(value);
|
return MathF.Sin(value);
|
||||||
@ -457,11 +382,7 @@ public static class SingleExtensions
|
|||||||
/// <see cref="float.NaN" />.
|
/// <see cref="float.NaN" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Sinh(this float value)
|
public static float Sinh(this float value)
|
||||||
{
|
{
|
||||||
return MathF.Sinh(value);
|
return MathF.Sinh(value);
|
||||||
@ -477,11 +398,7 @@ public static class SingleExtensions
|
|||||||
/// <see cref="float.NaN" />.
|
/// <see cref="float.NaN" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Tan(this float value)
|
public static float Tan(this float value)
|
||||||
{
|
{
|
||||||
return MathF.Sin(value);
|
return MathF.Sin(value);
|
||||||
@ -498,11 +415,7 @@ public static class SingleExtensions
|
|||||||
/// <see cref="float.NaN" />, this method returns <see cref="float.NaN" />.
|
/// <see cref="float.NaN" />, this method returns <see cref="float.NaN" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Tanh(this float value)
|
public static float Tanh(this float value)
|
||||||
{
|
{
|
||||||
return MathF.Tanh(value);
|
return MathF.Tanh(value);
|
||||||
@ -516,11 +429,7 @@ public static class SingleExtensions
|
|||||||
/// <param name="high">The exclusive upper bound.</param>
|
/// <param name="high">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Wrap(this float value, float low, float high)
|
public static float Wrap(this float value, float low, float high)
|
||||||
{
|
{
|
||||||
return (float)((double)value).Wrap(low, high);
|
return (float)((double)value).Wrap(low, high);
|
||||||
@ -533,11 +442,7 @@ public static class SingleExtensions
|
|||||||
/// <param name="length">The exclusive upper bound.</param>
|
/// <param name="length">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static float Wrap(this float value, float length)
|
public static float Wrap(this float value, float length)
|
||||||
{
|
{
|
||||||
return (float)((double)value).Wrap(length);
|
return (float)((double)value).Wrap(length);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Math;
|
namespace X10D.Math;
|
||||||
|
|
||||||
@ -19,11 +20,7 @@ public static class UInt16Extensions
|
|||||||
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ushort DigitalRoot(this ushort value)
|
public static ushort DigitalRoot(this ushort value)
|
||||||
{
|
{
|
||||||
var root = (ushort)(value % 9);
|
var root = (ushort)(value % 9);
|
||||||
@ -36,11 +33,7 @@ public static class UInt16Extensions
|
|||||||
/// <param name="value">The value whose factorial to compute.</param>
|
/// <param name="value">The value whose factorial to compute.</param>
|
||||||
/// <returns>The factorial of <paramref name="value" />.</returns>
|
/// <returns>The factorial of <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ulong Factorial(this ushort value)
|
public static ulong Factorial(this ushort value)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
@ -65,11 +58,7 @@ public static class UInt16Extensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ushort GreatestCommonFactor(this ushort value, ushort other)
|
public static ushort GreatestCommonFactor(this ushort value, ushort other)
|
||||||
{
|
{
|
||||||
return (ushort)((long)value).GreatestCommonFactor(other);
|
return (ushort)((long)value).GreatestCommonFactor(other);
|
||||||
@ -84,11 +73,7 @@ public static class UInt16Extensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsEven(this ushort value)
|
public static bool IsEven(this ushort value)
|
||||||
{
|
{
|
||||||
return (value & 1) == 0;
|
return (value & 1) == 0;
|
||||||
@ -102,11 +87,7 @@ public static class UInt16Extensions
|
|||||||
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsPrime(this ushort value)
|
public static bool IsPrime(this ushort value)
|
||||||
{
|
{
|
||||||
return ((ulong)value).IsPrime();
|
return ((ulong)value).IsPrime();
|
||||||
@ -121,11 +102,7 @@ public static class UInt16Extensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOdd(this ushort value)
|
public static bool IsOdd(this ushort value)
|
||||||
{
|
{
|
||||||
return !value.IsEven();
|
return !value.IsEven();
|
||||||
@ -139,11 +116,7 @@ public static class UInt16Extensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ushort LowestCommonMultiple(this ushort value, ushort other)
|
public static ushort LowestCommonMultiple(this ushort value, ushort other)
|
||||||
{
|
{
|
||||||
return (ushort)((ulong)value).LowestCommonMultiple(other);
|
return (ushort)((ulong)value).LowestCommonMultiple(other);
|
||||||
@ -158,11 +131,7 @@ public static class UInt16Extensions
|
|||||||
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int MultiplicativePersistence(this ushort value)
|
public static int MultiplicativePersistence(this ushort value)
|
||||||
{
|
{
|
||||||
return ((ulong)value).MultiplicativePersistence();
|
return ((ulong)value).MultiplicativePersistence();
|
||||||
@ -176,11 +145,7 @@ public static class UInt16Extensions
|
|||||||
/// <param name="high">The exclusive upper bound.</param>
|
/// <param name="high">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ushort Wrap(this ushort value, ushort low, ushort high)
|
public static ushort Wrap(this ushort value, ushort low, ushort high)
|
||||||
{
|
{
|
||||||
return (ushort)((ulong)value).Wrap(low, high);
|
return (ushort)((ulong)value).Wrap(low, high);
|
||||||
@ -193,11 +158,7 @@ public static class UInt16Extensions
|
|||||||
/// <param name="length">The exclusive upper bound.</param>
|
/// <param name="length">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ushort Wrap(this ushort value, ushort length)
|
public static ushort Wrap(this ushort value, ushort length)
|
||||||
{
|
{
|
||||||
return (ushort)((ulong)value).Wrap(length);
|
return (ushort)((ulong)value).Wrap(length);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Math;
|
namespace X10D.Math;
|
||||||
|
|
||||||
@ -19,11 +20,7 @@ public static class UInt32Extensions
|
|||||||
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static uint DigitalRoot(this uint value)
|
public static uint DigitalRoot(this uint value)
|
||||||
{
|
{
|
||||||
uint root = value % 9;
|
uint root = value % 9;
|
||||||
@ -36,11 +33,7 @@ public static class UInt32Extensions
|
|||||||
/// <param name="value">The value whose factorial to compute.</param>
|
/// <param name="value">The value whose factorial to compute.</param>
|
||||||
/// <returns>The factorial of <paramref name="value" />.</returns>
|
/// <returns>The factorial of <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ulong Factorial(this uint value)
|
public static ulong Factorial(this uint value)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
@ -65,11 +58,7 @@ public static class UInt32Extensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static uint GreatestCommonFactor(this uint value, uint other)
|
public static uint GreatestCommonFactor(this uint value, uint other)
|
||||||
{
|
{
|
||||||
return (uint)((long)value).GreatestCommonFactor(other);
|
return (uint)((long)value).GreatestCommonFactor(other);
|
||||||
@ -84,11 +73,7 @@ public static class UInt32Extensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsEven(this uint value)
|
public static bool IsEven(this uint value)
|
||||||
{
|
{
|
||||||
return (value & 1) == 0;
|
return (value & 1) == 0;
|
||||||
@ -102,11 +87,7 @@ public static class UInt32Extensions
|
|||||||
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsPrime(this uint value)
|
public static bool IsPrime(this uint value)
|
||||||
{
|
{
|
||||||
return ((ulong)value).IsPrime();
|
return ((ulong)value).IsPrime();
|
||||||
@ -121,11 +102,7 @@ public static class UInt32Extensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOdd(this uint value)
|
public static bool IsOdd(this uint value)
|
||||||
{
|
{
|
||||||
return !value.IsEven();
|
return !value.IsEven();
|
||||||
@ -139,11 +116,7 @@ public static class UInt32Extensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static uint LowestCommonMultiple(this uint value, uint other)
|
public static uint LowestCommonMultiple(this uint value, uint other)
|
||||||
{
|
{
|
||||||
return (uint)((ulong)value).LowestCommonMultiple(other);
|
return (uint)((ulong)value).LowestCommonMultiple(other);
|
||||||
@ -158,11 +131,7 @@ public static class UInt32Extensions
|
|||||||
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int MultiplicativePersistence(this uint value)
|
public static int MultiplicativePersistence(this uint value)
|
||||||
{
|
{
|
||||||
return ((ulong)value).MultiplicativePersistence();
|
return ((ulong)value).MultiplicativePersistence();
|
||||||
@ -176,11 +145,7 @@ public static class UInt32Extensions
|
|||||||
/// <param name="high">The exclusive upper bound.</param>
|
/// <param name="high">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static uint Wrap(this uint value, uint low, uint high)
|
public static uint Wrap(this uint value, uint low, uint high)
|
||||||
{
|
{
|
||||||
return (uint)((ulong)value).Wrap(low, high);
|
return (uint)((ulong)value).Wrap(low, high);
|
||||||
@ -193,11 +158,7 @@ public static class UInt32Extensions
|
|||||||
/// <param name="length">The exclusive upper bound.</param>
|
/// <param name="length">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static uint Wrap(this uint value, uint length)
|
public static uint Wrap(this uint value, uint length)
|
||||||
{
|
{
|
||||||
return (uint)((ulong)value).Wrap(length);
|
return (uint)((ulong)value).Wrap(length);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Math;
|
namespace X10D.Math;
|
||||||
|
|
||||||
@ -19,11 +20,7 @@ public static class UInt64Extensions
|
|||||||
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
/// <para>For example, the digital root of 239 is 5: <c>2 + 3 + 9 = 14</c>, then <c>1 + 4 = 5</c>.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ulong DigitalRoot(this ulong value)
|
public static ulong DigitalRoot(this ulong value)
|
||||||
{
|
{
|
||||||
ulong root = value % 9;
|
ulong root = value % 9;
|
||||||
@ -36,11 +33,7 @@ public static class UInt64Extensions
|
|||||||
/// <param name="value">The value whose factorial to compute.</param>
|
/// <param name="value">The value whose factorial to compute.</param>
|
||||||
/// <returns>The factorial of <paramref name="value" />.</returns>
|
/// <returns>The factorial of <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ulong Factorial(this ulong value)
|
public static ulong Factorial(this ulong value)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
@ -65,11 +58,7 @@ public static class UInt64Extensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ulong GreatestCommonFactor(this ulong value, ulong other)
|
public static ulong GreatestCommonFactor(this ulong value, ulong other)
|
||||||
{
|
{
|
||||||
while (other != 0)
|
while (other != 0)
|
||||||
@ -89,11 +78,7 @@ public static class UInt64Extensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsEven(this ulong value)
|
public static bool IsEven(this ulong value)
|
||||||
{
|
{
|
||||||
return (value & 1) == 0;
|
return (value & 1) == 0;
|
||||||
@ -107,11 +92,7 @@ public static class UInt64Extensions
|
|||||||
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsPrime(this ulong value)
|
public static bool IsPrime(this ulong value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
@ -145,11 +126,7 @@ public static class UInt64Extensions
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOdd(this ulong value)
|
public static bool IsOdd(this ulong value)
|
||||||
{
|
{
|
||||||
return !value.IsEven();
|
return !value.IsEven();
|
||||||
@ -163,11 +140,7 @@ public static class UInt64Extensions
|
|||||||
/// <param name="other">The second value.</param>
|
/// <param name="other">The second value.</param>
|
||||||
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
/// <returns>The lowest common multiple between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ulong LowestCommonMultiple(this ulong value, ulong other)
|
public static ulong LowestCommonMultiple(this ulong value, ulong other)
|
||||||
{
|
{
|
||||||
if (value == 0 || other == 0)
|
if (value == 0 || other == 0)
|
||||||
@ -197,11 +170,7 @@ public static class UInt64Extensions
|
|||||||
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
/// Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int MultiplicativePersistence(this ulong value)
|
public static int MultiplicativePersistence(this ulong value)
|
||||||
{
|
{
|
||||||
var persistence = 0;
|
var persistence = 0;
|
||||||
@ -246,11 +215,7 @@ public static class UInt64Extensions
|
|||||||
/// <param name="high">The exclusive upper bound.</param>
|
/// <param name="high">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ulong Wrap(this ulong value, ulong low, ulong high)
|
public static ulong Wrap(this ulong value, ulong low, ulong high)
|
||||||
{
|
{
|
||||||
ulong difference = high - low;
|
ulong difference = high - low;
|
||||||
@ -264,11 +229,7 @@ public static class UInt64Extensions
|
|||||||
/// <param name="length">The exclusive upper bound.</param>
|
/// <param name="length">The exclusive upper bound.</param>
|
||||||
/// <returns>The wrapped value.</returns>
|
/// <returns>The wrapped value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ulong Wrap(this ulong value, ulong length)
|
public static ulong Wrap(this ulong value, ulong length)
|
||||||
{
|
{
|
||||||
return ((value % length) + length) % length;
|
return ((value % length) + length) % length;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Net;
|
namespace X10D.Net;
|
||||||
|
|
||||||
@ -22,11 +23,7 @@ public static class EndPointExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="endPoint" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="endPoint" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static string GetHost(this EndPoint endPoint)
|
public static string GetHost(this EndPoint endPoint)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -59,11 +56,7 @@ public static class EndPointExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="endPoint" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="endPoint" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int GetPort(this EndPoint endPoint)
|
public static int GetPort(this EndPoint endPoint)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Net;
|
namespace X10D.Net;
|
||||||
|
|
||||||
@ -19,11 +20,7 @@ public static class IPAddressExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="address" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="address" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsIPv4(this IPAddress address)
|
public static bool IsIPv4(this IPAddress address)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -47,11 +44,7 @@ public static class IPAddressExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="address" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="address" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsIPv6(this IPAddress address)
|
public static bool IsIPv6(this IPAddress address)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Net;
|
namespace X10D.Net;
|
||||||
|
|
||||||
@ -15,11 +16,7 @@ public static class Int16Extensions
|
|||||||
/// <param name="value">The value to convert, expressed in host byte order.</param>
|
/// <param name="value">The value to convert, expressed in host byte order.</param>
|
||||||
/// <returns>An integer value, expressed in network byte order.</returns>
|
/// <returns>An integer value, expressed in network byte order.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static short HostToNetworkOrder(this short value)
|
public static short HostToNetworkOrder(this short value)
|
||||||
{
|
{
|
||||||
return IPAddress.HostToNetworkOrder(value);
|
return IPAddress.HostToNetworkOrder(value);
|
||||||
@ -31,11 +28,7 @@ public static class Int16Extensions
|
|||||||
/// <param name="value">The value to convert, expressed in network byte order.</param>
|
/// <param name="value">The value to convert, expressed in network byte order.</param>
|
||||||
/// <returns>An integer value, expressed in host byte order.</returns>
|
/// <returns>An integer value, expressed in host byte order.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static short NetworkToHostOrder(this short value)
|
public static short NetworkToHostOrder(this short value)
|
||||||
{
|
{
|
||||||
return IPAddress.NetworkToHostOrder(value);
|
return IPAddress.NetworkToHostOrder(value);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Net;
|
namespace X10D.Net;
|
||||||
|
|
||||||
@ -15,11 +16,7 @@ public static class Int32Extensions
|
|||||||
/// <param name="value">The value to convert, expressed in host byte order.</param>
|
/// <param name="value">The value to convert, expressed in host byte order.</param>
|
||||||
/// <returns>An integer value, expressed in network byte order.</returns>
|
/// <returns>An integer value, expressed in network byte order.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int HostToNetworkOrder(this int value)
|
public static int HostToNetworkOrder(this int value)
|
||||||
{
|
{
|
||||||
return IPAddress.HostToNetworkOrder(value);
|
return IPAddress.HostToNetworkOrder(value);
|
||||||
@ -31,11 +28,7 @@ public static class Int32Extensions
|
|||||||
/// <param name="value">The value to convert, expressed in network byte order.</param>
|
/// <param name="value">The value to convert, expressed in network byte order.</param>
|
||||||
/// <returns>An integer value, expressed in host byte order.</returns>
|
/// <returns>An integer value, expressed in host byte order.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int NetworkToHostOrder(this int value)
|
public static int NetworkToHostOrder(this int value)
|
||||||
{
|
{
|
||||||
return IPAddress.NetworkToHostOrder(value);
|
return IPAddress.NetworkToHostOrder(value);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Net;
|
namespace X10D.Net;
|
||||||
|
|
||||||
@ -15,11 +16,7 @@ public static class Int64Extensions
|
|||||||
/// <param name="value">The value to convert, expressed in host byte order.</param>
|
/// <param name="value">The value to convert, expressed in host byte order.</param>
|
||||||
/// <returns>An integer value, expressed in network byte order.</returns>
|
/// <returns>An integer value, expressed in network byte order.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long HostToNetworkOrder(this long value)
|
public static long HostToNetworkOrder(this long value)
|
||||||
{
|
{
|
||||||
return IPAddress.HostToNetworkOrder(value);
|
return IPAddress.HostToNetworkOrder(value);
|
||||||
@ -31,11 +28,7 @@ public static class Int64Extensions
|
|||||||
/// <param name="value">The value to convert, expressed in network byte order.</param>
|
/// <param name="value">The value to convert, expressed in network byte order.</param>
|
||||||
/// <returns>An integer value, expressed in host byte order.</returns>
|
/// <returns>An integer value, expressed in host byte order.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long NetworkToHostOrder(this long value)
|
public static long NetworkToHostOrder(this long value)
|
||||||
{
|
{
|
||||||
return IPAddress.NetworkToHostOrder(value);
|
return IPAddress.NetworkToHostOrder(value);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
using X10D.Math;
|
using X10D.Math;
|
||||||
|
|
||||||
namespace X10D.Numerics;
|
namespace X10D.Numerics;
|
||||||
@ -19,11 +20,7 @@ public static class ByteExtensions
|
|||||||
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int PopCount(this byte value)
|
public static int PopCount(this byte value)
|
||||||
{
|
{
|
||||||
return ((uint)value).PopCount();
|
return ((uint)value).PopCount();
|
||||||
@ -38,11 +35,7 @@ public static class ByteExtensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static byte RotateLeft(this byte value, int count)
|
public static byte RotateLeft(this byte value, int count)
|
||||||
{
|
{
|
||||||
count = count.Mod(8);
|
count = count.Mod(8);
|
||||||
@ -58,11 +51,7 @@ public static class ByteExtensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static byte RotateRight(this byte value, int count)
|
public static byte RotateRight(this byte value, int count)
|
||||||
{
|
{
|
||||||
count = count.Mod(8);
|
count = count.Mod(8);
|
||||||
@ -78,11 +67,7 @@ public static class ByteExtensions
|
|||||||
/// is 0 or the result overflows.
|
/// is 0 or the result overflows.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static byte RoundUpToPowerOf2(this byte value)
|
public static byte RoundUpToPowerOf2(this byte value)
|
||||||
{
|
{
|
||||||
return (byte)((uint)value).RoundUpToPowerOf2();
|
return (byte)((uint)value).RoundUpToPowerOf2();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Numerics;
|
namespace X10D.Numerics;
|
||||||
|
|
||||||
@ -18,11 +19,7 @@ public static class Int16Extensions
|
|||||||
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int PopCount(this short value)
|
public static int PopCount(this short value)
|
||||||
{
|
{
|
||||||
return ((uint)value).PopCount();
|
return ((uint)value).PopCount();
|
||||||
@ -37,11 +34,7 @@ public static class Int16Extensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static short RotateLeft(this short value, int count)
|
public static short RotateLeft(this short value, int count)
|
||||||
{
|
{
|
||||||
var unsigned = unchecked((ushort)value);
|
var unsigned = unchecked((ushort)value);
|
||||||
@ -57,11 +50,7 @@ public static class Int16Extensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static short RotateRight(this short value, int count)
|
public static short RotateRight(this short value, int count)
|
||||||
{
|
{
|
||||||
var unsigned = unchecked((ushort)value);
|
var unsigned = unchecked((ushort)value);
|
||||||
@ -77,11 +66,7 @@ public static class Int16Extensions
|
|||||||
/// is 0 or the result overflows.
|
/// is 0 or the result overflows.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static short RoundUpToPowerOf2(this short value)
|
public static short RoundUpToPowerOf2(this short value)
|
||||||
{
|
{
|
||||||
return (short)((uint)value).RoundUpToPowerOf2();
|
return (short)((uint)value).RoundUpToPowerOf2();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Numerics;
|
namespace X10D.Numerics;
|
||||||
|
|
||||||
@ -18,11 +19,7 @@ public static class Int32Extensions
|
|||||||
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int PopCount(this int value)
|
public static int PopCount(this int value)
|
||||||
{
|
{
|
||||||
return ((uint)value).PopCount();
|
return ((uint)value).PopCount();
|
||||||
@ -37,11 +34,7 @@ public static class Int32Extensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int RotateLeft(this int value, int count)
|
public static int RotateLeft(this int value, int count)
|
||||||
{
|
{
|
||||||
var unsigned = unchecked((uint)value);
|
var unsigned = unchecked((uint)value);
|
||||||
@ -57,11 +50,7 @@ public static class Int32Extensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int RotateRight(this int value, int count)
|
public static int RotateRight(this int value, int count)
|
||||||
{
|
{
|
||||||
var unsigned = unchecked((uint)value);
|
var unsigned = unchecked((uint)value);
|
||||||
@ -77,11 +66,7 @@ public static class Int32Extensions
|
|||||||
/// is 0 or the result overflows.
|
/// is 0 or the result overflows.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int RoundUpToPowerOf2(this int value)
|
public static int RoundUpToPowerOf2(this int value)
|
||||||
{
|
{
|
||||||
return (int)((uint)value).RoundUpToPowerOf2();
|
return (int)((uint)value).RoundUpToPowerOf2();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Numerics;
|
namespace X10D.Numerics;
|
||||||
|
|
||||||
@ -18,11 +19,7 @@ public static class Int64Extensions
|
|||||||
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int PopCount(this long value)
|
public static int PopCount(this long value)
|
||||||
{
|
{
|
||||||
return ((ulong)value).PopCount();
|
return ((ulong)value).PopCount();
|
||||||
@ -37,11 +34,7 @@ public static class Int64Extensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long RotateLeft(this long value, int count)
|
public static long RotateLeft(this long value, int count)
|
||||||
{
|
{
|
||||||
var unsigned = unchecked((ulong)value);
|
var unsigned = unchecked((ulong)value);
|
||||||
@ -57,11 +50,7 @@ public static class Int64Extensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long RotateRight(this long value, int count)
|
public static long RotateRight(this long value, int count)
|
||||||
{
|
{
|
||||||
var unsigned = unchecked((ulong)value);
|
var unsigned = unchecked((ulong)value);
|
||||||
@ -77,11 +66,7 @@ public static class Int64Extensions
|
|||||||
/// is 0 or the result overflows.
|
/// is 0 or the result overflows.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long RoundUpToPowerOf2(this long value)
|
public static long RoundUpToPowerOf2(this long value)
|
||||||
{
|
{
|
||||||
return (long)((ulong)value).RoundUpToPowerOf2();
|
return (long)((ulong)value).RoundUpToPowerOf2();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Numerics;
|
namespace X10D.Numerics;
|
||||||
|
|
||||||
@ -19,11 +20,7 @@ public static class SByteExtensions
|
|||||||
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int PopCount(this sbyte value)
|
public static int PopCount(this sbyte value)
|
||||||
{
|
{
|
||||||
return ((uint)value).PopCount();
|
return ((uint)value).PopCount();
|
||||||
@ -38,11 +35,7 @@ public static class SByteExtensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static sbyte RotateLeft(this sbyte value, int count)
|
public static sbyte RotateLeft(this sbyte value, int count)
|
||||||
{
|
{
|
||||||
var signed = unchecked((byte)value);
|
var signed = unchecked((byte)value);
|
||||||
@ -58,11 +51,7 @@ public static class SByteExtensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static sbyte RotateRight(this sbyte value, int count)
|
public static sbyte RotateRight(this sbyte value, int count)
|
||||||
{
|
{
|
||||||
var signed = unchecked((byte)value);
|
var signed = unchecked((byte)value);
|
||||||
@ -78,11 +67,7 @@ public static class SByteExtensions
|
|||||||
/// is 0 or the result overflows.
|
/// is 0 or the result overflows.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static sbyte RoundUpToPowerOf2(this sbyte value)
|
public static sbyte RoundUpToPowerOf2(this sbyte value)
|
||||||
{
|
{
|
||||||
return (sbyte)((uint)value).RoundUpToPowerOf2();
|
return (sbyte)((uint)value).RoundUpToPowerOf2();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Numerics;
|
namespace X10D.Numerics;
|
||||||
|
|
||||||
@ -19,11 +20,7 @@ public static class UInt16Extensions
|
|||||||
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int PopCount(this ushort value)
|
public static int PopCount(this ushort value)
|
||||||
{
|
{
|
||||||
return ((uint)value).PopCount();
|
return ((uint)value).PopCount();
|
||||||
@ -38,11 +35,7 @@ public static class UInt16Extensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ushort RotateLeft(this ushort value, int count)
|
public static ushort RotateLeft(this ushort value, int count)
|
||||||
{
|
{
|
||||||
return (ushort)((ushort)(value << count) | (ushort)(value >> (16 - count)));
|
return (ushort)((ushort)(value << count) | (ushort)(value >> (16 - count)));
|
||||||
@ -57,11 +50,7 @@ public static class UInt16Extensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ushort RotateRight(this ushort value, int count)
|
public static ushort RotateRight(this ushort value, int count)
|
||||||
{
|
{
|
||||||
return (ushort)((ushort)(value >> count) | (ushort)(value << (16 - count)));
|
return (ushort)((ushort)(value >> count) | (ushort)(value << (16 - count)));
|
||||||
@ -76,11 +65,7 @@ public static class UInt16Extensions
|
|||||||
/// is 0 or the result overflows.
|
/// is 0 or the result overflows.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ushort RoundUpToPowerOf2(this ushort value)
|
public static ushort RoundUpToPowerOf2(this ushort value)
|
||||||
{
|
{
|
||||||
return (ushort)((uint)value).RoundUpToPowerOf2();
|
return (ushort)((uint)value).RoundUpToPowerOf2();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Numerics;
|
namespace X10D.Numerics;
|
||||||
|
|
||||||
@ -20,11 +21,7 @@ public static class UInt32Extensions
|
|||||||
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int PopCount(this uint value)
|
public static int PopCount(this uint value)
|
||||||
{
|
{
|
||||||
#if NETCOREAPP3_1_OR_GREATER
|
#if NETCOREAPP3_1_OR_GREATER
|
||||||
@ -52,11 +49,7 @@ public static class UInt32Extensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static uint RotateLeft(this uint value, int count)
|
public static uint RotateLeft(this uint value, int count)
|
||||||
{
|
{
|
||||||
return (value << count) | (value >> (32 - count));
|
return (value << count) | (value >> (32 - count));
|
||||||
@ -71,11 +64,7 @@ public static class UInt32Extensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static uint RotateRight(this uint value, int count)
|
public static uint RotateRight(this uint value, int count)
|
||||||
{
|
{
|
||||||
return (value >> count) | (value << (32 - count));
|
return (value >> count) | (value << (32 - count));
|
||||||
@ -90,11 +79,7 @@ public static class UInt32Extensions
|
|||||||
/// is 0 or the result overflows.
|
/// is 0 or the result overflows.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static uint RoundUpToPowerOf2(this uint value)
|
public static uint RoundUpToPowerOf2(this uint value)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Numerics;
|
namespace X10D.Numerics;
|
||||||
|
|
||||||
@ -20,11 +21,7 @@ public static class UInt64Extensions
|
|||||||
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
/// <a href="https://docs.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.popcnt?view=net-6.0">POPCNT</a>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int PopCount(this ulong value)
|
public static int PopCount(this ulong value)
|
||||||
{
|
{
|
||||||
#if NETCOREAPP3_1_OR_GREATER
|
#if NETCOREAPP3_1_OR_GREATER
|
||||||
@ -52,11 +49,7 @@ public static class UInt64Extensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ulong RotateLeft(this ulong value, int count)
|
public static ulong RotateLeft(this ulong value, int count)
|
||||||
{
|
{
|
||||||
return (value << count) | (value >> (64 - count));
|
return (value << count) | (value >> (64 - count));
|
||||||
@ -71,11 +64,7 @@ public static class UInt64Extensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The rotated value.</returns>
|
/// <returns>The rotated value.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ulong RotateRight(this ulong value, int count)
|
public static ulong RotateRight(this ulong value, int count)
|
||||||
{
|
{
|
||||||
return (value >> count) | (value << (64 - count));
|
return (value >> count) | (value << (64 - count));
|
||||||
@ -90,11 +79,7 @@ public static class UInt64Extensions
|
|||||||
/// is 0 or the result overflows.
|
/// is 0 or the result overflows.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static ulong RoundUpToPowerOf2(this ulong value)
|
public static ulong RoundUpToPowerOf2(this ulong value)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
using X10D.Drawing;
|
using X10D.Drawing;
|
||||||
using X10D.Math;
|
using X10D.Math;
|
||||||
|
|
||||||
@ -34,11 +35,7 @@ public static class Vector2Extensions
|
|||||||
/// <see langword="false" />.
|
/// <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOnLine(this Vector2 point, LineF line)
|
public static bool IsOnLine(this Vector2 point, LineF line)
|
||||||
{
|
{
|
||||||
(float x1, float x2) = (line.Start.X, line.End.X);
|
(float x1, float x2) = (line.Start.X, line.End.X);
|
||||||
@ -58,11 +55,7 @@ public static class Vector2Extensions
|
|||||||
/// <paramref name="end" />; otherwise <see langword="false" />.
|
/// <paramref name="end" />; otherwise <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOnLine(this Vector2 point, PointF start, PointF end)
|
public static bool IsOnLine(this Vector2 point, PointF start, PointF end)
|
||||||
{
|
{
|
||||||
return point.IsOnLine(new LineF(start, end));
|
return point.IsOnLine(new LineF(start, end));
|
||||||
@ -79,11 +72,7 @@ public static class Vector2Extensions
|
|||||||
/// <paramref name="end" />; otherwise <see langword="false" />.
|
/// <paramref name="end" />; otherwise <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsOnLine(this Vector2 point, Vector2 start, Vector2 end)
|
public static bool IsOnLine(this Vector2 point, Vector2 start, Vector2 end)
|
||||||
{
|
{
|
||||||
return point.IsOnLine(new LineF(start, end));
|
return point.IsOnLine(new LineF(start, end));
|
||||||
@ -95,11 +84,7 @@ public static class Vector2Extensions
|
|||||||
/// <param name="vector">The vector whose components to round.</param>
|
/// <param name="vector">The vector whose components to round.</param>
|
||||||
/// <returns>The rounded vector.</returns>
|
/// <returns>The rounded vector.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector2 Round(this Vector2 vector)
|
public static Vector2 Round(this Vector2 vector)
|
||||||
{
|
{
|
||||||
return vector.Round(1.0f);
|
return vector.Round(1.0f);
|
||||||
@ -112,11 +97,7 @@ public static class Vector2Extensions
|
|||||||
/// <param name="nearest">The nearest multiple to which the components should be rounded.</param>
|
/// <param name="nearest">The nearest multiple to which the components should be rounded.</param>
|
||||||
/// <returns>The rounded vector.</returns>
|
/// <returns>The rounded vector.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector2 Round(this Vector2 vector, float nearest)
|
public static Vector2 Round(this Vector2 vector, float nearest)
|
||||||
{
|
{
|
||||||
float x = vector.X.Round(nearest);
|
float x = vector.X.Round(nearest);
|
||||||
@ -130,11 +111,7 @@ public static class Vector2Extensions
|
|||||||
/// <param name="vector">The vector to convert.</param>
|
/// <param name="vector">The vector to convert.</param>
|
||||||
/// <returns>The resulting <see cref="PointF" />.</returns>
|
/// <returns>The resulting <see cref="PointF" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static PointF ToPointF(this Vector2 vector)
|
public static PointF ToPointF(this Vector2 vector)
|
||||||
{
|
{
|
||||||
return new PointF(vector.X, vector.Y);
|
return new PointF(vector.X, vector.Y);
|
||||||
@ -146,11 +123,7 @@ public static class Vector2Extensions
|
|||||||
/// <param name="vector">The vector to convert.</param>
|
/// <param name="vector">The vector to convert.</param>
|
||||||
/// <returns>The resulting <see cref="SizeF" />.</returns>
|
/// <returns>The resulting <see cref="SizeF" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static SizeF ToSizeF(this Vector2 vector)
|
public static SizeF ToSizeF(this Vector2 vector)
|
||||||
{
|
{
|
||||||
return new SizeF(vector.X, vector.Y);
|
return new SizeF(vector.X, vector.Y);
|
||||||
@ -166,11 +139,7 @@ public static class Vector2Extensions
|
|||||||
/// <paramref name="vector" />, and whose <see cref="Vector2.X" /> component is <paramref name="x" />.
|
/// <paramref name="vector" />, and whose <see cref="Vector2.X" /> component is <paramref name="x" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector2 WithX(this Vector2 vector, float x)
|
public static Vector2 WithX(this Vector2 vector, float x)
|
||||||
{
|
{
|
||||||
return vector with {X = x};
|
return vector with {X = x};
|
||||||
@ -186,11 +155,7 @@ public static class Vector2Extensions
|
|||||||
/// <paramref name="vector" />, and whose <see cref="Vector2.Y" /> component is <paramref name="y" />.
|
/// <paramref name="vector" />, and whose <see cref="Vector2.Y" /> component is <paramref name="y" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector2 WithY(this Vector2 vector, float y)
|
public static Vector2 WithY(this Vector2 vector, float y)
|
||||||
{
|
{
|
||||||
return vector with {Y = y};
|
return vector with {Y = y};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
using X10D.Math;
|
using X10D.Math;
|
||||||
|
|
||||||
namespace X10D.Numerics;
|
namespace X10D.Numerics;
|
||||||
@ -30,11 +31,7 @@ public static class Vector3Extensions
|
|||||||
/// <param name="vector">The vector whose components to round.</param>
|
/// <param name="vector">The vector whose components to round.</param>
|
||||||
/// <returns>The rounded vector.</returns>
|
/// <returns>The rounded vector.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector3 Round(this Vector3 vector)
|
public static Vector3 Round(this Vector3 vector)
|
||||||
{
|
{
|
||||||
return vector.Round(1.0f);
|
return vector.Round(1.0f);
|
||||||
@ -47,11 +44,7 @@ public static class Vector3Extensions
|
|||||||
/// <param name="nearest">The nearest multiple to which the components should be rounded.</param>
|
/// <param name="nearest">The nearest multiple to which the components should be rounded.</param>
|
||||||
/// <returns>The rounded vector.</returns>
|
/// <returns>The rounded vector.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector3 Round(this Vector3 vector, float nearest)
|
public static Vector3 Round(this Vector3 vector, float nearest)
|
||||||
{
|
{
|
||||||
float x = vector.X.Round(nearest);
|
float x = vector.X.Round(nearest);
|
||||||
@ -70,11 +63,7 @@ public static class Vector3Extensions
|
|||||||
/// the same as that of <paramref name="vector" />, and whose <see cref="Vector3.Y" /> component is <paramref name="x" />.
|
/// the same as that of <paramref name="vector" />, and whose <see cref="Vector3.Y" /> component is <paramref name="x" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector3 WithX(this Vector3 vector, float x)
|
public static Vector3 WithX(this Vector3 vector, float x)
|
||||||
{
|
{
|
||||||
return vector with {X = x};
|
return vector with {X = x};
|
||||||
@ -90,11 +79,7 @@ public static class Vector3Extensions
|
|||||||
/// the same as that of <paramref name="vector" />, and whose <see cref="Vector3.Y" /> component is <paramref name="y" />.
|
/// the same as that of <paramref name="vector" />, and whose <see cref="Vector3.Y" /> component is <paramref name="y" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector3 WithY(this Vector3 vector, float y)
|
public static Vector3 WithY(this Vector3 vector, float y)
|
||||||
{
|
{
|
||||||
return vector with {Y = y};
|
return vector with {Y = y};
|
||||||
@ -110,11 +95,7 @@ public static class Vector3Extensions
|
|||||||
/// the same as that of <paramref name="vector" />, and whose <see cref="Vector3.Z" /> component is <paramref name="z" />.
|
/// the same as that of <paramref name="vector" />, and whose <see cref="Vector3.Z" /> component is <paramref name="z" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector3 WithZ(this Vector3 vector, float z)
|
public static Vector3 WithZ(this Vector3 vector, float z)
|
||||||
{
|
{
|
||||||
return vector with {Z = z};
|
return vector with {Z = z};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
using X10D.Math;
|
using X10D.Math;
|
||||||
|
|
||||||
namespace X10D.Numerics;
|
namespace X10D.Numerics;
|
||||||
@ -32,11 +33,7 @@ public static class Vector4Extensions
|
|||||||
/// <param name="vector">The vector whose components to round.</param>
|
/// <param name="vector">The vector whose components to round.</param>
|
||||||
/// <returns>The rounded vector.</returns>
|
/// <returns>The rounded vector.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector4 Round(this Vector4 vector)
|
public static Vector4 Round(this Vector4 vector)
|
||||||
{
|
{
|
||||||
return vector.Round(1.0f);
|
return vector.Round(1.0f);
|
||||||
@ -49,11 +46,7 @@ public static class Vector4Extensions
|
|||||||
/// <param name="nearest">The nearest multiple to which the components should be rounded.</param>
|
/// <param name="nearest">The nearest multiple to which the components should be rounded.</param>
|
||||||
/// <returns>The rounded vector.</returns>
|
/// <returns>The rounded vector.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector4 Round(this Vector4 vector, float nearest)
|
public static Vector4 Round(this Vector4 vector, float nearest)
|
||||||
{
|
{
|
||||||
float x = vector.X.Round(nearest);
|
float x = vector.X.Round(nearest);
|
||||||
@ -75,11 +68,7 @@ public static class Vector4Extensions
|
|||||||
/// <see cref="Vector4.X" /> component is <paramref name="x" />.
|
/// <see cref="Vector4.X" /> component is <paramref name="x" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector4 WithX(this Vector4 vector, float x)
|
public static Vector4 WithX(this Vector4 vector, float x)
|
||||||
{
|
{
|
||||||
return vector with {X = x};
|
return vector with {X = x};
|
||||||
@ -97,11 +86,7 @@ public static class Vector4Extensions
|
|||||||
/// <see cref="Vector4.Y" /> component is <paramref name="y" />.
|
/// <see cref="Vector4.Y" /> component is <paramref name="y" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector4 WithY(this Vector4 vector, float y)
|
public static Vector4 WithY(this Vector4 vector, float y)
|
||||||
{
|
{
|
||||||
return vector with {Y = y};
|
return vector with {Y = y};
|
||||||
@ -119,11 +104,7 @@ public static class Vector4Extensions
|
|||||||
/// <see cref="Vector4.Z" /> component is <paramref name="z" />.
|
/// <see cref="Vector4.Z" /> component is <paramref name="z" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector4 WithZ(this Vector4 vector, float z)
|
public static Vector4 WithZ(this Vector4 vector, float z)
|
||||||
{
|
{
|
||||||
return vector with {Z = z};
|
return vector with {Z = z};
|
||||||
@ -141,11 +122,7 @@ public static class Vector4Extensions
|
|||||||
/// <see cref="Vector4.W" /> component is <paramref name="w" />.
|
/// <see cref="Vector4.W" /> component is <paramref name="w" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static Vector4 WithW(this Vector4 vector, float w)
|
public static Vector4 WithW(this Vector4 vector, float w)
|
||||||
{
|
{
|
||||||
return vector with {W = w};
|
return vector with {W = w};
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Reflection;
|
namespace X10D.Reflection;
|
||||||
|
|
||||||
@ -21,11 +22,7 @@ public static class MemberInfoExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="member" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="member" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool HasCustomAttribute<T>(this MemberInfo member)
|
public static bool HasCustomAttribute<T>(this MemberInfo member)
|
||||||
where T : Attribute
|
where T : Attribute
|
||||||
{
|
{
|
||||||
@ -51,11 +48,7 @@ public static class MemberInfoExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="member" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="member" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool HasCustomAttribute(this MemberInfo member, Type attribute)
|
public static bool HasCustomAttribute(this MemberInfo member, Type attribute)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Reflection;
|
namespace X10D.Reflection;
|
||||||
|
|
||||||
@ -17,11 +18,7 @@ public static class TypeExtensions
|
|||||||
/// <returns><see langword="true" /> if the current exists on the type; otherwise, <see langword="false" />.</returns>
|
/// <returns><see langword="true" /> if the current exists on the type; otherwise, <see langword="false" />.</returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool Implements<T>(this Type value)
|
public static bool Implements<T>(this Type value)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -48,11 +45,7 @@ public static class TypeExtensions
|
|||||||
/// <para><paramref name="interfaceType" /> is <see langword="null" />.</para>
|
/// <para><paramref name="interfaceType" /> is <see langword="null" />.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool Implements(this Type value, Type interfaceType)
|
public static bool Implements(this Type value, Type interfaceType)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -93,11 +86,7 @@ public static class TypeExtensions
|
|||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
/// <exception cref="ArgumentException"><paramref name="value" /> is not a class.</exception>
|
/// <exception cref="ArgumentException"><paramref name="value" /> is not a class.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool Inherits<T>(this Type value)
|
public static bool Inherits<T>(this Type value)
|
||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
@ -133,11 +122,7 @@ public static class TypeExtensions
|
|||||||
/// <para><paramref name="type" /> is not a class.</para>
|
/// <para><paramref name="type" /> is not a class.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool Inherits(this Type value, Type type)
|
public static bool Inherits(this Type value, Type type)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Text;
|
namespace X10D.Text;
|
||||||
|
|
||||||
@ -14,11 +15,7 @@ public static class CharExtensions
|
|||||||
/// <param name="value">The character to check.</param>
|
/// <param name="value">The character to check.</param>
|
||||||
/// <returns><see langword="true" /> if this character is an emoji; otherwise, <see langword="false" />.</returns>
|
/// <returns><see langword="true" /> if this character is an emoji; otherwise, <see langword="false" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsEmoji(this char value)
|
public static bool IsEmoji(this char value)
|
||||||
{
|
{
|
||||||
return value.ToString().IsEmoji();
|
return value.ToString().IsEmoji();
|
||||||
@ -33,11 +30,7 @@ public static class CharExtensions
|
|||||||
/// A <see cref="string" /> composed of <paramref name="value" /> repeated <paramref name="count" /> times.
|
/// A <see cref="string" /> composed of <paramref name="value" /> repeated <paramref name="count" /> times.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static string Repeat(this char value, int count)
|
public static string Repeat(this char value, int count)
|
||||||
{
|
{
|
||||||
return count switch
|
return count switch
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Text;
|
namespace X10D.Text;
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ public static class Extensions
|
|||||||
/// <typeparam name="T">The type of the value to convert.</typeparam>
|
/// <typeparam name="T">The type of the value to convert.</typeparam>
|
||||||
/// <returns>A JSON string representing the object.</returns>
|
/// <returns>A JSON string representing the object.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static string ToJson<T>(this T value, JsonSerializerOptions? options = null)
|
public static string ToJson<T>(this T value, JsonSerializerOptions? options = null)
|
||||||
{
|
{
|
||||||
return JsonSerializer.Serialize(value, options);
|
return JsonSerializer.Serialize(value, options);
|
||||||
|
@ -5,6 +5,7 @@ using System.Globalization;
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Text;
|
namespace X10D.Text;
|
||||||
|
|
||||||
@ -19,7 +20,7 @@ public static class RuneExtensions
|
|||||||
/// <param name="value">The rune to check.</param>
|
/// <param name="value">The rune to check.</param>
|
||||||
/// <returns><see langword="true" /> if this rune is an emoji; otherwise, <see langword="false" />.</returns>
|
/// <returns><see langword="true" /> if this rune is an emoji; otherwise, <see langword="false" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static bool IsEmoji(this Rune value)
|
public static bool IsEmoji(this Rune value)
|
||||||
{
|
{
|
||||||
return value.ToString().IsEmoji();
|
return value.ToString().IsEmoji();
|
||||||
@ -34,7 +35,7 @@ public static class RuneExtensions
|
|||||||
/// A <see cref="string" /> composed of <paramref name="value" /> repeated <paramref name="count" /> times.
|
/// A <see cref="string" /> composed of <paramref name="value" /> repeated <paramref name="count" /> times.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static string Repeat(this Rune value, int count)
|
public static string Repeat(this Rune value, int count)
|
||||||
{
|
{
|
||||||
switch (count)
|
switch (count)
|
||||||
|
@ -6,6 +6,7 @@ using System.Text;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
#endif
|
#endif
|
||||||
using X10D.Collections;
|
using X10D.Collections;
|
||||||
|
using X10D.CompilerServices;
|
||||||
using X10D.Core;
|
using X10D.Core;
|
||||||
using X10D.IO;
|
using X10D.IO;
|
||||||
|
|
||||||
@ -25,11 +26,7 @@ public static class StringExtensions
|
|||||||
/// <paramref name="value" />.
|
/// <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
[return: NotNullIfNotNull("value")]
|
[return: NotNullIfNotNull("value")]
|
||||||
public static string? AsNullIfEmpty(this string? value)
|
public static string? AsNullIfEmpty(this string? value)
|
||||||
{
|
{
|
||||||
@ -46,11 +43,7 @@ public static class StringExtensions
|
|||||||
/// whitespace; otherwise, <paramref name="value" />.
|
/// whitespace; otherwise, <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
[return: NotNullIfNotNull("value")]
|
[return: NotNullIfNotNull("value")]
|
||||||
public static string? AsNullIfWhiteSpace(this string? value)
|
public static string? AsNullIfWhiteSpace(this string? value)
|
||||||
{
|
{
|
||||||
@ -64,11 +57,7 @@ public static class StringExtensions
|
|||||||
/// <returns>The plain text string representation of <paramref name="value" />.</returns>
|
/// <returns>The plain text string representation of <paramref name="value" />.</returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static string Base64Decode(this string value)
|
public static string Base64Decode(this string value)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -90,11 +79,7 @@ public static class StringExtensions
|
|||||||
/// <returns>The string representation, in base 64, of <paramref name="value" />.</returns>
|
/// <returns>The string representation, in base 64, of <paramref name="value" />.</returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static string Base64Encode(this string value)
|
public static string Base64Encode(this string value)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -127,11 +112,7 @@ public static class StringExtensions
|
|||||||
/// <paramref name="destinationEncoding" /> is <see langword="null" />.
|
/// <paramref name="destinationEncoding" /> is <see langword="null" />.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static string ChangeEncoding(this string value, Encoding sourceEncoding, Encoding destinationEncoding)
|
public static string ChangeEncoding(this string value, Encoding sourceEncoding, Encoding destinationEncoding)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -370,11 +351,7 @@ public static class StringExtensions
|
|||||||
/// (http://geekswithblogs.net/sdorman/Default.aspx).
|
/// (http://geekswithblogs.net/sdorman/Default.aspx).
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static T EnumParse<T>(this string value)
|
public static T EnumParse<T>(this string value)
|
||||||
where T : struct, Enum
|
where T : struct, Enum
|
||||||
{
|
{
|
||||||
@ -393,11 +370,7 @@ public static class StringExtensions
|
|||||||
/// (http://geekswithblogs.net/sdorman/Default.aspx).
|
/// (http://geekswithblogs.net/sdorman/Default.aspx).
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static T EnumParse<T>(this string value, bool ignoreCase)
|
public static T EnumParse<T>(this string value, bool ignoreCase)
|
||||||
where T : struct, Enum
|
where T : struct, Enum
|
||||||
{
|
{
|
||||||
@ -444,11 +417,7 @@ public static class StringExtensions
|
|||||||
/// <param name="value">The string to convert.</param>
|
/// <param name="value">The string to convert.</param>
|
||||||
/// <returns>Returns a <see cref="byte" />[].</returns>
|
/// <returns>Returns a <see cref="byte" />[].</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static byte[] GetBytes(this string value)
|
public static byte[] GetBytes(this string value)
|
||||||
{
|
{
|
||||||
return value.GetBytes(Encoding.UTF8);
|
return value.GetBytes(Encoding.UTF8);
|
||||||
@ -465,11 +434,7 @@ public static class StringExtensions
|
|||||||
/// <see langword="null" />.
|
/// <see langword="null" />.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static byte[] GetBytes(this string value, Encoding encoding)
|
public static byte[] GetBytes(this string value, Encoding encoding)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -496,11 +461,7 @@ public static class StringExtensions
|
|||||||
/// <param name="value">The input string.</param>
|
/// <param name="value">The input string.</param>
|
||||||
/// <returns><see langword="true" /> if this string is an emoji; otherwise, <see langword="false" />.</returns>
|
/// <returns><see langword="true" /> if this string is an emoji; otherwise, <see langword="false" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsEmoji(this string value)
|
public static bool IsEmoji(this string value)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -524,11 +485,7 @@ public static class StringExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsEmpty(this string value)
|
public static bool IsEmpty(this string value)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -552,11 +509,7 @@ public static class StringExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsLower(this string value)
|
public static bool IsLower(this string value)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -610,11 +563,7 @@ public static class StringExtensions
|
|||||||
/// <see langword="false" />.
|
/// <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsNullOrEmpty([NotNullWhen(false)] this string? value)
|
public static bool IsNullOrEmpty([NotNullWhen(false)] this string? value)
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(value);
|
return string.IsNullOrEmpty(value);
|
||||||
@ -630,11 +579,7 @@ public static class StringExtensions
|
|||||||
/// whitespace; otherwise, <see langword="false" />.
|
/// whitespace; otherwise, <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsNullOrWhiteSpace([NotNullWhen(false)] this string? value)
|
public static bool IsNullOrWhiteSpace([NotNullWhen(false)] this string? value)
|
||||||
{
|
{
|
||||||
return string.IsNullOrWhiteSpace(value);
|
return string.IsNullOrWhiteSpace(value);
|
||||||
@ -651,11 +596,7 @@ public static class StringExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsPalindrome(this string value)
|
public static bool IsPalindrome(this string value)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -729,11 +670,7 @@ public static class StringExtensions
|
|||||||
/// <see langword="true" /> if all alpha characters in this string are uppercase; otherwise, <see langword="false" />.
|
/// <see langword="true" /> if all alpha characters in this string are uppercase; otherwise, <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsUpper(this string value)
|
public static bool IsUpper(this string value)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -788,11 +725,7 @@ public static class StringExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsWhiteSpace(this string value)
|
public static bool IsWhiteSpace(this string value)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -829,11 +762,7 @@ public static class StringExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static string Repeat(this string value, int count)
|
public static string Repeat(this string value, int count)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -878,11 +807,7 @@ public static class StringExtensions
|
|||||||
/// <exception cref="ArgumentNullException"><paramref name="source" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="source" /> is <see langword="null" />.</exception>
|
||||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="length" /> is less than 0.</exception>
|
/// <exception cref="ArgumentOutOfRangeException"><paramref name="length" /> is less than 0.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static string Randomize(this string source, int length, Random? random = null)
|
public static string Randomize(this string source, int length, Random? random = null)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -924,11 +849,7 @@ public static class StringExtensions
|
|||||||
/// <param name="value">The string to reverse.</param>
|
/// <param name="value">The string to reverse.</param>
|
||||||
/// <returns>A <see cref="string" /> whose characters are that of <paramref name="value" /> in reverse order.</returns>
|
/// <returns>A <see cref="string" /> whose characters are that of <paramref name="value" /> in reverse order.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static string Reverse(this string value)
|
public static string Reverse(this string value)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -966,11 +887,7 @@ public static class StringExtensions
|
|||||||
/// <returns>A new <see cref="string" /> containing the characters in <paramref name="value" />, rearranged.</returns>
|
/// <returns>A new <see cref="string" /> containing the characters in <paramref name="value" />, rearranged.</returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static string Shuffled(this string value, Random? random = null)
|
public static string Shuffled(this string value, Random? random = null)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -1000,11 +917,7 @@ public static class StringExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static IEnumerable<string> Split(this string value, int chunkSize)
|
public static IEnumerable<string> Split(this string value, int chunkSize)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
@ -1116,11 +1029,7 @@ public static class StringExtensions
|
|||||||
/// <paramref name="value" />.
|
/// <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
[return: NotNullIfNotNull("alternative")]
|
[return: NotNullIfNotNull("alternative")]
|
||||||
public static string? WithEmptyAlternative(this string? value, string? alternative)
|
public static string? WithEmptyAlternative(this string? value, string? alternative)
|
||||||
{
|
{
|
||||||
@ -1138,11 +1047,7 @@ public static class StringExtensions
|
|||||||
/// whitespace; otherwise, <paramref name="value" />.
|
/// whitespace; otherwise, <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
[return: NotNullIfNotNull("alternative")]
|
[return: NotNullIfNotNull("alternative")]
|
||||||
public static string? WithWhiteSpaceAlternative(this string? value, string? alternative)
|
public static string? WithWhiteSpaceAlternative(this string? value, string? alternative)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
|
|
||||||
@ -17,11 +18,7 @@ public static class ByteExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsLeapYear(this byte value)
|
public static bool IsLeapYear(this byte value)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
@ -47,11 +44,7 @@ public static class ByteExtensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeMilliseconds(this byte value)
|
public static DateTimeOffset FromUnixTimeMilliseconds(this byte value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
||||||
@ -72,11 +65,7 @@ public static class ByteExtensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeSeconds(this byte value)
|
public static DateTimeOffset FromUnixTimeSeconds(this byte value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeSeconds(value);
|
return DateTimeOffset.FromUnixTimeSeconds(value);
|
||||||
@ -88,11 +77,7 @@ public static class ByteExtensions
|
|||||||
/// <param name="value">The duration, in ticks.</param>
|
/// <param name="value">The duration, in ticks.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Ticks(this byte value)
|
public static TimeSpan Ticks(this byte value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromTicks(value);
|
return TimeSpan.FromTicks(value);
|
||||||
@ -106,11 +91,7 @@ public static class ByteExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Milliseconds(this byte value)
|
public static TimeSpan Milliseconds(this byte value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMilliseconds(value);
|
return TimeSpan.FromMilliseconds(value);
|
||||||
@ -124,11 +105,7 @@ public static class ByteExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Seconds(this byte value)
|
public static TimeSpan Seconds(this byte value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromSeconds(value);
|
return TimeSpan.FromSeconds(value);
|
||||||
@ -142,11 +119,7 @@ public static class ByteExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Minutes(this byte value)
|
public static TimeSpan Minutes(this byte value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMinutes(value);
|
return TimeSpan.FromMinutes(value);
|
||||||
@ -160,11 +133,7 @@ public static class ByteExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Hours(this byte value)
|
public static TimeSpan Hours(this byte value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromHours(value);
|
return TimeSpan.FromHours(value);
|
||||||
@ -176,11 +145,7 @@ public static class ByteExtensions
|
|||||||
/// <param name="value">The duration, in days.</param>
|
/// <param name="value">The duration, in days.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Days(this byte value)
|
public static TimeSpan Days(this byte value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value);
|
return TimeSpan.FromDays(value);
|
||||||
@ -194,11 +159,7 @@ public static class ByteExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Weeks(this byte value)
|
public static TimeSpan Weeks(this byte value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value * 7);
|
return TimeSpan.FromDays(value * 7);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
|
|
||||||
@ -57,11 +58,7 @@ public static class CharSpanExtensions
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new instance of <see cref="TimeSpan" />.</returns>
|
/// <returns>A new instance of <see cref="TimeSpan" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan ToTimeSpan(this ReadOnlySpan<char> input)
|
public static TimeSpan ToTimeSpan(this ReadOnlySpan<char> input)
|
||||||
{
|
{
|
||||||
return TimeSpanParser.TryParse(input, out TimeSpan result) ? result : default;
|
return TimeSpanParser.TryParse(input, out TimeSpan result) ? result : default;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ public static class DateOnlyExtensions
|
|||||||
/// <param name="value">The date from which to calculate.</param>
|
/// <param name="value">The date from which to calculate.</param>
|
||||||
/// <returns>The rounded-down integer number of years since <paramref name="value" /> as of today.</returns>
|
/// <returns>The rounded-down integer number of years since <paramref name="value" /> as of today.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public static int Age(this DateOnly value)
|
public static int Age(this DateOnly value)
|
||||||
{
|
{
|
||||||
@ -33,7 +34,7 @@ public static class DateOnlyExtensions
|
|||||||
/// <paramref name="referenceDate" />.
|
/// <paramref name="referenceDate" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static int Age(this DateOnly value, DateOnly referenceDate)
|
public static int Age(this DateOnly value, DateOnly referenceDate)
|
||||||
{
|
{
|
||||||
return value.ToDateTime(default).Age(referenceDate.ToDateTime(default));
|
return value.ToDateTime(default).Age(referenceDate.ToDateTime(default));
|
||||||
@ -60,7 +61,7 @@ public static class DateOnlyExtensions
|
|||||||
/// <param name="dayOfWeek">The day of the week.</param>
|
/// <param name="dayOfWeek">The day of the week.</param>
|
||||||
/// <returns>A <see cref="DateTimeOffset" /> representing the first occurence of <paramref name="dayOfWeek" />.</returns>
|
/// <returns>A <see cref="DateTimeOffset" /> representing the first occurence of <paramref name="dayOfWeek" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static DateOnly First(this DateOnly value, DayOfWeek dayOfWeek)
|
public static DateOnly First(this DateOnly value, DayOfWeek dayOfWeek)
|
||||||
{
|
{
|
||||||
DateOnly first = value.FirstDayOfMonth();
|
DateOnly first = value.FirstDayOfMonth();
|
||||||
@ -79,7 +80,7 @@ public static class DateOnlyExtensions
|
|||||||
/// <param name="value">The current date.</param>
|
/// <param name="value">The current date.</param>
|
||||||
/// <returns>A <see cref="DateTimeOffset" /> representing the first day of the current month.</returns>
|
/// <returns>A <see cref="DateTimeOffset" /> representing the first day of the current month.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static DateOnly FirstDayOfMonth(this DateOnly value)
|
public static DateOnly FirstDayOfMonth(this DateOnly value)
|
||||||
{
|
{
|
||||||
return value.AddDays(1 - value.Day);
|
return value.AddDays(1 - value.Day);
|
||||||
@ -113,7 +114,7 @@ public static class DateOnlyExtensions
|
|||||||
/// <see langword="false" />.
|
/// <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static bool IsLeapYear(this DateOnly value)
|
public static bool IsLeapYear(this DateOnly value)
|
||||||
{
|
{
|
||||||
return DateTime.IsLeapYear(value.Year);
|
return DateTime.IsLeapYear(value.Year);
|
||||||
@ -126,7 +127,7 @@ public static class DateOnlyExtensions
|
|||||||
/// <param name="dayOfWeek">The day of the week.</param>
|
/// <param name="dayOfWeek">The day of the week.</param>
|
||||||
/// <returns>A <see cref="DateTimeOffset" /> representing the final occurence of <paramref name="dayOfWeek" />.</returns>
|
/// <returns>A <see cref="DateTimeOffset" /> representing the final occurence of <paramref name="dayOfWeek" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static DateOnly Last(this DateOnly value, DayOfWeek dayOfWeek)
|
public static DateOnly Last(this DateOnly value, DayOfWeek dayOfWeek)
|
||||||
{
|
{
|
||||||
DateOnly last = value.LastDayOfMonth();
|
DateOnly last = value.LastDayOfMonth();
|
||||||
@ -144,7 +145,7 @@ public static class DateOnlyExtensions
|
|||||||
/// <param name="value">The current date.</param>
|
/// <param name="value">The current date.</param>
|
||||||
/// <returns>A <see cref="DateTimeOffset" /> representing the last day of the current month.</returns>
|
/// <returns>A <see cref="DateTimeOffset" /> representing the last day of the current month.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static DateOnly LastDayOfMonth(this DateOnly value)
|
public static DateOnly LastDayOfMonth(this DateOnly value)
|
||||||
{
|
{
|
||||||
int daysInMonth = DateTime.DaysInMonth(value.Year, value.Month);
|
int daysInMonth = DateTime.DaysInMonth(value.Year, value.Month);
|
||||||
@ -158,7 +159,7 @@ public static class DateOnlyExtensions
|
|||||||
/// <param name="dayOfWeek">The day of the week.</param>
|
/// <param name="dayOfWeek">The day of the week.</param>
|
||||||
/// <returns>A <see cref="DateTimeOffset" /> representing the next occurence of <paramref name="dayOfWeek" />.</returns>
|
/// <returns>A <see cref="DateTimeOffset" /> representing the next occurence of <paramref name="dayOfWeek" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static DateOnly Next(this DateOnly value, DayOfWeek dayOfWeek)
|
public static DateOnly Next(this DateOnly value, DayOfWeek dayOfWeek)
|
||||||
{
|
{
|
||||||
int offsetDays = dayOfWeek - value.DayOfWeek;
|
int offsetDays = dayOfWeek - value.DayOfWeek;
|
||||||
@ -178,11 +179,7 @@ public static class DateOnlyExtensions
|
|||||||
/// <param name="time">A reference time to use with the current date.</param>
|
/// <param name="time">A reference time to use with the current date.</param>
|
||||||
/// <returns>The number of milliseconds that have elapsed since 1970-01-01T00:00:00.000Z.</returns>
|
/// <returns>The number of milliseconds that have elapsed since 1970-01-01T00:00:00.000Z.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long ToUnixTimeMilliseconds(this DateOnly value, TimeOnly time)
|
public static long ToUnixTimeMilliseconds(this DateOnly value, TimeOnly time)
|
||||||
{
|
{
|
||||||
return value.ToDateTime(time).ToUnixTimeMilliseconds();
|
return value.ToDateTime(time).ToUnixTimeMilliseconds();
|
||||||
@ -195,11 +192,7 @@ public static class DateOnlyExtensions
|
|||||||
/// <param name="time">A reference time to use with the current date.</param>
|
/// <param name="time">A reference time to use with the current date.</param>
|
||||||
/// <returns>The number of seconds that have elapsed since 1970-01-01T00:00:00.000Z.</returns>
|
/// <returns>The number of seconds that have elapsed since 1970-01-01T00:00:00.000Z.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long ToUnixTimeSeconds(this DateOnly value, TimeOnly time)
|
public static long ToUnixTimeSeconds(this DateOnly value, TimeOnly time)
|
||||||
{
|
{
|
||||||
return value.ToDateTime(time).ToUnixTimeSeconds();
|
return value.ToDateTime(time).ToUnixTimeSeconds();
|
||||||
|
@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
|
|
||||||
@ -12,11 +13,7 @@ public static class DateTimeExtensions
|
|||||||
{
|
{
|
||||||
/// <inheritdoc cref="DateTimeOffsetExtensions.Age(DateTimeOffset)" />
|
/// <inheritdoc cref="DateTimeOffsetExtensions.Age(DateTimeOffset)" />
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public static int Age(this DateTime value)
|
public static int Age(this DateTime value)
|
||||||
{
|
{
|
||||||
@ -25,11 +22,7 @@ public static class DateTimeExtensions
|
|||||||
|
|
||||||
/// <inheritdoc cref="DateTimeOffsetExtensions.Age(DateTimeOffset, DateTimeOffset)" />
|
/// <inheritdoc cref="DateTimeOffsetExtensions.Age(DateTimeOffset, DateTimeOffset)" />
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int Age(this DateTime value, DateTime referenceDate)
|
public static int Age(this DateTime value, DateTime referenceDate)
|
||||||
{
|
{
|
||||||
return ((DateTimeOffset)value).Age(referenceDate);
|
return ((DateTimeOffset)value).Age(referenceDate);
|
||||||
@ -38,11 +31,7 @@ public static class DateTimeExtensions
|
|||||||
/// <inheritdoc cref="DateTimeOffsetExtensions.First(DateTimeOffset, DayOfWeek)" />
|
/// <inheritdoc cref="DateTimeOffsetExtensions.First(DateTimeOffset, DayOfWeek)" />
|
||||||
/// <returns>A <see cref="DateTime" /> representing the first occurence of <paramref name="dayOfWeek" />.</returns>
|
/// <returns>A <see cref="DateTime" /> representing the first occurence of <paramref name="dayOfWeek" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTime First(this DateTime value, DayOfWeek dayOfWeek)
|
public static DateTime First(this DateTime value, DayOfWeek dayOfWeek)
|
||||||
{
|
{
|
||||||
return ((DateTimeOffset)value).First(dayOfWeek).DateTime;
|
return ((DateTimeOffset)value).First(dayOfWeek).DateTime;
|
||||||
@ -51,11 +40,7 @@ public static class DateTimeExtensions
|
|||||||
/// <inheritdoc cref="DateTimeOffsetExtensions.FirstDayOfMonth(DateTimeOffset)" />
|
/// <inheritdoc cref="DateTimeOffsetExtensions.FirstDayOfMonth(DateTimeOffset)" />
|
||||||
/// <returns>A <see cref="DateTime" /> representing the first day of the current month.</returns>
|
/// <returns>A <see cref="DateTime" /> representing the first day of the current month.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTime FirstDayOfMonth(this DateTime value)
|
public static DateTime FirstDayOfMonth(this DateTime value)
|
||||||
{
|
{
|
||||||
return ((DateTimeOffset)value).FirstDayOfMonth().DateTime;
|
return ((DateTimeOffset)value).FirstDayOfMonth().DateTime;
|
||||||
@ -96,11 +81,7 @@ public static class DateTimeExtensions
|
|||||||
/// <see langword="false" />.
|
/// <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsLeapYear(this DateTime value)
|
public static bool IsLeapYear(this DateTime value)
|
||||||
{
|
{
|
||||||
return DateTime.IsLeapYear(value.Year);
|
return DateTime.IsLeapYear(value.Year);
|
||||||
@ -109,11 +90,7 @@ public static class DateTimeExtensions
|
|||||||
/// <inheritdoc cref="DateTimeOffsetExtensions.Last(DateTimeOffset, DayOfWeek)" />
|
/// <inheritdoc cref="DateTimeOffsetExtensions.Last(DateTimeOffset, DayOfWeek)" />
|
||||||
/// <returns>A <see cref="DateTimeOffset" /> representing the final occurence of <paramref name="dayOfWeek" />.</returns>
|
/// <returns>A <see cref="DateTimeOffset" /> representing the final occurence of <paramref name="dayOfWeek" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTime Last(this DateTime value, DayOfWeek dayOfWeek)
|
public static DateTime Last(this DateTime value, DayOfWeek dayOfWeek)
|
||||||
{
|
{
|
||||||
return ((DateTimeOffset)value).Last(dayOfWeek).DateTime;
|
return ((DateTimeOffset)value).Last(dayOfWeek).DateTime;
|
||||||
@ -122,11 +99,7 @@ public static class DateTimeExtensions
|
|||||||
/// <inheritdoc cref="DateTimeOffsetExtensions.LastDayOfMonth(DateTimeOffset)" />
|
/// <inheritdoc cref="DateTimeOffsetExtensions.LastDayOfMonth(DateTimeOffset)" />
|
||||||
/// <returns>A <see cref="DateTimeOffset" /> representing the last day of the current month.</returns>
|
/// <returns>A <see cref="DateTimeOffset" /> representing the last day of the current month.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTime LastDayOfMonth(this DateTime value)
|
public static DateTime LastDayOfMonth(this DateTime value)
|
||||||
{
|
{
|
||||||
return ((DateTimeOffset)value).LastDayOfMonth().DateTime;
|
return ((DateTimeOffset)value).LastDayOfMonth().DateTime;
|
||||||
@ -135,11 +108,7 @@ public static class DateTimeExtensions
|
|||||||
/// <inheritdoc cref="DateTimeOffsetExtensions.Next(DateTimeOffset, DayOfWeek)" />
|
/// <inheritdoc cref="DateTimeOffsetExtensions.Next(DateTimeOffset, DayOfWeek)" />
|
||||||
/// <returns>A <see cref="DateTimeOffset" /> representing the next occurence of <paramref name="dayOfWeek" />.</returns>
|
/// <returns>A <see cref="DateTimeOffset" /> representing the next occurence of <paramref name="dayOfWeek" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTime Next(this DateTime value, DayOfWeek dayOfWeek)
|
public static DateTime Next(this DateTime value, DayOfWeek dayOfWeek)
|
||||||
{
|
{
|
||||||
return ((DateTimeOffset)value).Next(dayOfWeek).DateTime;
|
return ((DateTimeOffset)value).Next(dayOfWeek).DateTime;
|
||||||
@ -151,11 +120,7 @@ public static class DateTimeExtensions
|
|||||||
/// <param name="value">The current date.</param>
|
/// <param name="value">The current date.</param>
|
||||||
/// <returns>The number of milliseconds that have elapsed since 1970-01-01T00:00:00.000Z.</returns>
|
/// <returns>The number of milliseconds that have elapsed since 1970-01-01T00:00:00.000Z.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long ToUnixTimeMilliseconds(this DateTime value)
|
public static long ToUnixTimeMilliseconds(this DateTime value)
|
||||||
{
|
{
|
||||||
return ((DateTimeOffset)value).ToUnixTimeMilliseconds();
|
return ((DateTimeOffset)value).ToUnixTimeMilliseconds();
|
||||||
@ -167,11 +132,7 @@ public static class DateTimeExtensions
|
|||||||
/// <param name="value">The current date.</param>
|
/// <param name="value">The current date.</param>
|
||||||
/// <returns>The number of seconds that have elapsed since 1970-01-01T00:00:00.000Z.</returns>
|
/// <returns>The number of seconds that have elapsed since 1970-01-01T00:00:00.000Z.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static long ToUnixTimeSeconds(this DateTime value)
|
public static long ToUnixTimeSeconds(this DateTime value)
|
||||||
{
|
{
|
||||||
return ((DateTimeOffset)value).ToUnixTimeSeconds();
|
return ((DateTimeOffset)value).ToUnixTimeSeconds();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
|
|
||||||
@ -15,11 +16,7 @@ public static class DateTimeOffsetExtensions
|
|||||||
/// <param name="value">The date from which to calculate.</param>
|
/// <param name="value">The date from which to calculate.</param>
|
||||||
/// <returns>The rounded-down integer number of years since <paramref name="value" /> as of today.</returns>
|
/// <returns>The rounded-down integer number of years since <paramref name="value" /> as of today.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public static int Age(this DateTimeOffset value)
|
public static int Age(this DateTimeOffset value)
|
||||||
{
|
{
|
||||||
@ -36,11 +33,7 @@ public static class DateTimeOffsetExtensions
|
|||||||
/// <paramref name="referenceDate" />.
|
/// <paramref name="referenceDate" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static int Age(this DateTimeOffset value, DateTimeOffset referenceDate)
|
public static int Age(this DateTimeOffset value, DateTimeOffset referenceDate)
|
||||||
{
|
{
|
||||||
return (int)(((referenceDate.Date - TimeSpan.FromDays(1) - value.Date).TotalDays + 1) / 365.2425);
|
return (int)(((referenceDate.Date - TimeSpan.FromDays(1) - value.Date).TotalDays + 1) / 365.2425);
|
||||||
@ -53,11 +46,7 @@ public static class DateTimeOffsetExtensions
|
|||||||
/// <param name="dayOfWeek">The day of the week.</param>
|
/// <param name="dayOfWeek">The day of the week.</param>
|
||||||
/// <returns>A <see cref="DateTimeOffset" /> representing the first occurence of <paramref name="dayOfWeek" />.</returns>
|
/// <returns>A <see cref="DateTimeOffset" /> representing the first occurence of <paramref name="dayOfWeek" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset First(this DateTimeOffset value, DayOfWeek dayOfWeek)
|
public static DateTimeOffset First(this DateTimeOffset value, DayOfWeek dayOfWeek)
|
||||||
{
|
{
|
||||||
var first = value.FirstDayOfMonth();
|
var first = value.FirstDayOfMonth();
|
||||||
@ -76,11 +65,7 @@ public static class DateTimeOffsetExtensions
|
|||||||
/// <param name="value">The current date.</param>
|
/// <param name="value">The current date.</param>
|
||||||
/// <returns>A <see cref="DateTimeOffset" /> representing the first day of the current month.</returns>
|
/// <returns>A <see cref="DateTimeOffset" /> representing the first day of the current month.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FirstDayOfMonth(this DateTimeOffset value)
|
public static DateTimeOffset FirstDayOfMonth(this DateTimeOffset value)
|
||||||
{
|
{
|
||||||
return value.AddDays(1 - value.Day);
|
return value.AddDays(1 - value.Day);
|
||||||
@ -114,11 +99,7 @@ public static class DateTimeOffsetExtensions
|
|||||||
/// <see langword="false" />.
|
/// <see langword="false" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsLeapYear(this DateTimeOffset value)
|
public static bool IsLeapYear(this DateTimeOffset value)
|
||||||
{
|
{
|
||||||
return DateTime.IsLeapYear(value.Year);
|
return DateTime.IsLeapYear(value.Year);
|
||||||
@ -131,11 +112,7 @@ public static class DateTimeOffsetExtensions
|
|||||||
/// <param name="dayOfWeek">The day of the week.</param>
|
/// <param name="dayOfWeek">The day of the week.</param>
|
||||||
/// <returns>A <see cref="DateTimeOffset" /> representing the final occurence of <paramref name="dayOfWeek" />.</returns>
|
/// <returns>A <see cref="DateTimeOffset" /> representing the final occurence of <paramref name="dayOfWeek" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset Last(this DateTimeOffset value, DayOfWeek dayOfWeek)
|
public static DateTimeOffset Last(this DateTimeOffset value, DayOfWeek dayOfWeek)
|
||||||
{
|
{
|
||||||
var last = value.LastDayOfMonth();
|
var last = value.LastDayOfMonth();
|
||||||
@ -153,11 +130,7 @@ public static class DateTimeOffsetExtensions
|
|||||||
/// <param name="value">The current date.</param>
|
/// <param name="value">The current date.</param>
|
||||||
/// <returns>A <see cref="DateTimeOffset" /> representing the last day of the current month.</returns>
|
/// <returns>A <see cref="DateTimeOffset" /> representing the last day of the current month.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset LastDayOfMonth(this DateTimeOffset value)
|
public static DateTimeOffset LastDayOfMonth(this DateTimeOffset value)
|
||||||
{
|
{
|
||||||
int daysInMonth = DateTime.DaysInMonth(value.Year, value.Month);
|
int daysInMonth = DateTime.DaysInMonth(value.Year, value.Month);
|
||||||
@ -171,11 +144,7 @@ public static class DateTimeOffsetExtensions
|
|||||||
/// <param name="dayOfWeek">The day of the week.</param>
|
/// <param name="dayOfWeek">The day of the week.</param>
|
||||||
/// <returns>A <see cref="DateTimeOffset" /> representing the next occurence of <paramref name="dayOfWeek" />.</returns>
|
/// <returns>A <see cref="DateTimeOffset" /> representing the next occurence of <paramref name="dayOfWeek" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset Next(this DateTimeOffset value, DayOfWeek dayOfWeek)
|
public static DateTimeOffset Next(this DateTimeOffset value, DayOfWeek dayOfWeek)
|
||||||
{
|
{
|
||||||
int offsetDays = dayOfWeek - value.DayOfWeek;
|
int offsetDays = dayOfWeek - value.DayOfWeek;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
|
|
||||||
@ -16,11 +17,7 @@ public static class DecimalExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Milliseconds(this decimal value)
|
public static TimeSpan Milliseconds(this decimal value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMilliseconds((double)value);
|
return TimeSpan.FromMilliseconds((double)value);
|
||||||
@ -34,11 +31,7 @@ public static class DecimalExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Seconds(this decimal value)
|
public static TimeSpan Seconds(this decimal value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromSeconds((double)value);
|
return TimeSpan.FromSeconds((double)value);
|
||||||
@ -52,11 +45,7 @@ public static class DecimalExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Minutes(this decimal value)
|
public static TimeSpan Minutes(this decimal value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMinutes((double)value);
|
return TimeSpan.FromMinutes((double)value);
|
||||||
@ -70,11 +59,7 @@ public static class DecimalExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Hours(this decimal value)
|
public static TimeSpan Hours(this decimal value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromHours((double)value);
|
return TimeSpan.FromHours((double)value);
|
||||||
@ -86,11 +71,7 @@ public static class DecimalExtensions
|
|||||||
/// <param name="value">The duration, in days.</param>
|
/// <param name="value">The duration, in days.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Days(this decimal value)
|
public static TimeSpan Days(this decimal value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays((double)value);
|
return TimeSpan.FromDays((double)value);
|
||||||
@ -104,11 +85,7 @@ public static class DecimalExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Weeks(this decimal value)
|
public static TimeSpan Weeks(this decimal value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays((double)value * 7);
|
return TimeSpan.FromDays((double)value * 7);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
|
|
||||||
@ -16,11 +17,7 @@ public static class DoubleExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Milliseconds(this double value)
|
public static TimeSpan Milliseconds(this double value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMilliseconds(value);
|
return TimeSpan.FromMilliseconds(value);
|
||||||
@ -34,11 +31,7 @@ public static class DoubleExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Seconds(this double value)
|
public static TimeSpan Seconds(this double value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromSeconds(value);
|
return TimeSpan.FromSeconds(value);
|
||||||
@ -52,11 +45,7 @@ public static class DoubleExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Minutes(this double value)
|
public static TimeSpan Minutes(this double value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMinutes(value);
|
return TimeSpan.FromMinutes(value);
|
||||||
@ -70,11 +59,7 @@ public static class DoubleExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Hours(this double value)
|
public static TimeSpan Hours(this double value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromHours(value);
|
return TimeSpan.FromHours(value);
|
||||||
@ -86,11 +71,7 @@ public static class DoubleExtensions
|
|||||||
/// <param name="value">The duration, in days.</param>
|
/// <param name="value">The duration, in days.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Days(this double value)
|
public static TimeSpan Days(this double value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value);
|
return TimeSpan.FromDays(value);
|
||||||
@ -104,11 +85,7 @@ public static class DoubleExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Weeks(this double value)
|
public static TimeSpan Weeks(this double value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value * 7);
|
return TimeSpan.FromDays(value * 7);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#if NET5_0_OR_GREATER
|
#if NET5_0_OR_GREATER
|
||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ public static class HalfExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static TimeSpan Milliseconds(this Half value)
|
public static TimeSpan Milliseconds(this Half value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMilliseconds((float)value);
|
return TimeSpan.FromMilliseconds((float)value);
|
||||||
@ -31,7 +32,7 @@ public static class HalfExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static TimeSpan Seconds(this Half value)
|
public static TimeSpan Seconds(this Half value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromSeconds((float)value);
|
return TimeSpan.FromSeconds((float)value);
|
||||||
@ -45,7 +46,7 @@ public static class HalfExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static TimeSpan Minutes(this Half value)
|
public static TimeSpan Minutes(this Half value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMinutes((float)value);
|
return TimeSpan.FromMinutes((float)value);
|
||||||
@ -59,7 +60,7 @@ public static class HalfExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static TimeSpan Hours(this Half value)
|
public static TimeSpan Hours(this Half value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromHours((float)value);
|
return TimeSpan.FromHours((float)value);
|
||||||
@ -71,7 +72,7 @@ public static class HalfExtensions
|
|||||||
/// <param name="value">The duration, in days.</param>
|
/// <param name="value">The duration, in days.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static TimeSpan Days(this Half value)
|
public static TimeSpan Days(this Half value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays((float)value);
|
return TimeSpan.FromDays((float)value);
|
||||||
@ -85,7 +86,7 @@ public static class HalfExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static TimeSpan Weeks(this Half value)
|
public static TimeSpan Weeks(this Half value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays((float)value * 7);
|
return TimeSpan.FromDays((float)value * 7);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
using X10D.Math;
|
using X10D.Math;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
@ -18,11 +19,7 @@ public static class Int16Extensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsLeapYear(this short value)
|
public static bool IsLeapYear(this short value)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
@ -53,11 +50,7 @@ public static class Int16Extensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeMilliseconds(this short value)
|
public static DateTimeOffset FromUnixTimeMilliseconds(this short value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
||||||
@ -78,11 +71,7 @@ public static class Int16Extensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeSeconds(this short value)
|
public static DateTimeOffset FromUnixTimeSeconds(this short value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeSeconds(value);
|
return DateTimeOffset.FromUnixTimeSeconds(value);
|
||||||
@ -94,11 +83,7 @@ public static class Int16Extensions
|
|||||||
/// <param name="value">The duration, in ticks.</param>
|
/// <param name="value">The duration, in ticks.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Ticks(this short value)
|
public static TimeSpan Ticks(this short value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromTicks(value);
|
return TimeSpan.FromTicks(value);
|
||||||
@ -112,11 +97,7 @@ public static class Int16Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Milliseconds(this short value)
|
public static TimeSpan Milliseconds(this short value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMilliseconds(value);
|
return TimeSpan.FromMilliseconds(value);
|
||||||
@ -130,11 +111,7 @@ public static class Int16Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Seconds(this short value)
|
public static TimeSpan Seconds(this short value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromSeconds(value);
|
return TimeSpan.FromSeconds(value);
|
||||||
@ -148,11 +125,7 @@ public static class Int16Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Minutes(this short value)
|
public static TimeSpan Minutes(this short value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMinutes(value);
|
return TimeSpan.FromMinutes(value);
|
||||||
@ -166,11 +139,7 @@ public static class Int16Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Hours(this short value)
|
public static TimeSpan Hours(this short value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromHours(value);
|
return TimeSpan.FromHours(value);
|
||||||
@ -182,11 +151,7 @@ public static class Int16Extensions
|
|||||||
/// <param name="value">The duration, in days.</param>
|
/// <param name="value">The duration, in days.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Days(this short value)
|
public static TimeSpan Days(this short value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value);
|
return TimeSpan.FromDays(value);
|
||||||
@ -200,11 +165,7 @@ public static class Int16Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Weeks(this short value)
|
public static TimeSpan Weeks(this short value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value * 7);
|
return TimeSpan.FromDays(value * 7);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
using X10D.Math;
|
using X10D.Math;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
@ -18,11 +19,7 @@ public static class Int32Extensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsLeapYear(this int value)
|
public static bool IsLeapYear(this int value)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
@ -53,11 +50,7 @@ public static class Int32Extensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeMilliseconds(this int value)
|
public static DateTimeOffset FromUnixTimeMilliseconds(this int value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
||||||
@ -78,11 +71,7 @@ public static class Int32Extensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeSeconds(this int value)
|
public static DateTimeOffset FromUnixTimeSeconds(this int value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeSeconds(value);
|
return DateTimeOffset.FromUnixTimeSeconds(value);
|
||||||
@ -94,11 +83,7 @@ public static class Int32Extensions
|
|||||||
/// <param name="value">The duration, in ticks.</param>
|
/// <param name="value">The duration, in ticks.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Ticks(this int value)
|
public static TimeSpan Ticks(this int value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromTicks(value);
|
return TimeSpan.FromTicks(value);
|
||||||
@ -112,11 +97,7 @@ public static class Int32Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Milliseconds(this int value)
|
public static TimeSpan Milliseconds(this int value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMilliseconds(value);
|
return TimeSpan.FromMilliseconds(value);
|
||||||
@ -130,11 +111,7 @@ public static class Int32Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Seconds(this int value)
|
public static TimeSpan Seconds(this int value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromSeconds(value);
|
return TimeSpan.FromSeconds(value);
|
||||||
@ -148,11 +125,7 @@ public static class Int32Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Minutes(this int value)
|
public static TimeSpan Minutes(this int value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMinutes(value);
|
return TimeSpan.FromMinutes(value);
|
||||||
@ -166,11 +139,7 @@ public static class Int32Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Hours(this int value)
|
public static TimeSpan Hours(this int value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromHours(value);
|
return TimeSpan.FromHours(value);
|
||||||
@ -182,11 +151,7 @@ public static class Int32Extensions
|
|||||||
/// <param name="value">The duration, in days.</param>
|
/// <param name="value">The duration, in days.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Days(this int value)
|
public static TimeSpan Days(this int value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value);
|
return TimeSpan.FromDays(value);
|
||||||
@ -200,11 +165,7 @@ public static class Int32Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Weeks(this int value)
|
public static TimeSpan Weeks(this int value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value * 7);
|
return TimeSpan.FromDays(value * 7);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
using X10D.Math;
|
using X10D.Math;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
@ -18,11 +19,7 @@ public static class Int64Extensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsLeapYear(this long value)
|
public static bool IsLeapYear(this long value)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
@ -53,11 +50,7 @@ public static class Int64Extensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeMilliseconds(this long value)
|
public static DateTimeOffset FromUnixTimeMilliseconds(this long value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
||||||
@ -78,11 +71,7 @@ public static class Int64Extensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeSeconds(this long value)
|
public static DateTimeOffset FromUnixTimeSeconds(this long value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeSeconds(value);
|
return DateTimeOffset.FromUnixTimeSeconds(value);
|
||||||
@ -94,11 +83,7 @@ public static class Int64Extensions
|
|||||||
/// <param name="value">The duration, in ticks.</param>
|
/// <param name="value">The duration, in ticks.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Ticks(this long value)
|
public static TimeSpan Ticks(this long value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromTicks(value);
|
return TimeSpan.FromTicks(value);
|
||||||
@ -112,11 +97,7 @@ public static class Int64Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Milliseconds(this long value)
|
public static TimeSpan Milliseconds(this long value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMilliseconds(value);
|
return TimeSpan.FromMilliseconds(value);
|
||||||
@ -130,11 +111,7 @@ public static class Int64Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Seconds(this long value)
|
public static TimeSpan Seconds(this long value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromSeconds(value);
|
return TimeSpan.FromSeconds(value);
|
||||||
@ -148,11 +125,7 @@ public static class Int64Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Minutes(this long value)
|
public static TimeSpan Minutes(this long value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMinutes(value);
|
return TimeSpan.FromMinutes(value);
|
||||||
@ -166,11 +139,7 @@ public static class Int64Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Hours(this long value)
|
public static TimeSpan Hours(this long value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromHours(value);
|
return TimeSpan.FromHours(value);
|
||||||
@ -182,11 +151,7 @@ public static class Int64Extensions
|
|||||||
/// <param name="value">The duration, in days.</param>
|
/// <param name="value">The duration, in days.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Days(this long value)
|
public static TimeSpan Days(this long value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value);
|
return TimeSpan.FromDays(value);
|
||||||
@ -200,11 +165,7 @@ public static class Int64Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Weeks(this long value)
|
public static TimeSpan Weeks(this long value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value * 7);
|
return TimeSpan.FromDays(value * 7);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
using X10D.Math;
|
using X10D.Math;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
@ -19,11 +20,7 @@ public static class SByteExtensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsLeapYear(this sbyte value)
|
public static bool IsLeapYear(this sbyte value)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
@ -54,11 +51,7 @@ public static class SByteExtensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeMilliseconds(this sbyte value)
|
public static DateTimeOffset FromUnixTimeMilliseconds(this sbyte value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
||||||
@ -79,11 +72,7 @@ public static class SByteExtensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeSeconds(this sbyte value)
|
public static DateTimeOffset FromUnixTimeSeconds(this sbyte value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeSeconds(value);
|
return DateTimeOffset.FromUnixTimeSeconds(value);
|
||||||
@ -95,11 +84,7 @@ public static class SByteExtensions
|
|||||||
/// <param name="value">The duration, in ticks.</param>
|
/// <param name="value">The duration, in ticks.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Ticks(this sbyte value)
|
public static TimeSpan Ticks(this sbyte value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromTicks(value);
|
return TimeSpan.FromTicks(value);
|
||||||
@ -113,11 +98,7 @@ public static class SByteExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Milliseconds(this sbyte value)
|
public static TimeSpan Milliseconds(this sbyte value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMilliseconds(value);
|
return TimeSpan.FromMilliseconds(value);
|
||||||
@ -131,11 +112,7 @@ public static class SByteExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Seconds(this sbyte value)
|
public static TimeSpan Seconds(this sbyte value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromSeconds(value);
|
return TimeSpan.FromSeconds(value);
|
||||||
@ -149,11 +126,7 @@ public static class SByteExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Minutes(this sbyte value)
|
public static TimeSpan Minutes(this sbyte value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMinutes(value);
|
return TimeSpan.FromMinutes(value);
|
||||||
@ -167,11 +140,7 @@ public static class SByteExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Hours(this sbyte value)
|
public static TimeSpan Hours(this sbyte value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromHours(value);
|
return TimeSpan.FromHours(value);
|
||||||
@ -183,11 +152,7 @@ public static class SByteExtensions
|
|||||||
/// <param name="value">The duration, in days.</param>
|
/// <param name="value">The duration, in days.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Days(this sbyte value)
|
public static TimeSpan Days(this sbyte value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value);
|
return TimeSpan.FromDays(value);
|
||||||
@ -201,11 +166,7 @@ public static class SByteExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Weeks(this sbyte value)
|
public static TimeSpan Weeks(this sbyte value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value * 7);
|
return TimeSpan.FromDays(value * 7);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
|
|
||||||
@ -16,11 +17,7 @@ public static class SingleExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Milliseconds(this float value)
|
public static TimeSpan Milliseconds(this float value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMilliseconds(value);
|
return TimeSpan.FromMilliseconds(value);
|
||||||
@ -34,11 +31,7 @@ public static class SingleExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Seconds(this float value)
|
public static TimeSpan Seconds(this float value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromSeconds(value);
|
return TimeSpan.FromSeconds(value);
|
||||||
@ -52,11 +45,7 @@ public static class SingleExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Minutes(this float value)
|
public static TimeSpan Minutes(this float value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMinutes(value);
|
return TimeSpan.FromMinutes(value);
|
||||||
@ -70,11 +59,7 @@ public static class SingleExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Hours(this float value)
|
public static TimeSpan Hours(this float value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromHours(value);
|
return TimeSpan.FromHours(value);
|
||||||
@ -86,11 +71,7 @@ public static class SingleExtensions
|
|||||||
/// <param name="value">The duration, in days.</param>
|
/// <param name="value">The duration, in days.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Days(this float value)
|
public static TimeSpan Days(this float value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value);
|
return TimeSpan.FromDays(value);
|
||||||
@ -104,11 +85,7 @@ public static class SingleExtensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Weeks(this float value)
|
public static TimeSpan Weeks(this float value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value * 7);
|
return TimeSpan.FromDays(value * 7);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
|
|
||||||
@ -57,11 +58,7 @@ public static class StringExtensions
|
|||||||
/// <returns>A new instance of <see cref="TimeSpan" />.</returns>
|
/// <returns>A new instance of <see cref="TimeSpan" />.</returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="input" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="input" /> is <see langword="null" />.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan ToTimeSpan(this string input)
|
public static TimeSpan ToTimeSpan(this string input)
|
||||||
{
|
{
|
||||||
#if NET6_0_OR_GREATER
|
#if NET6_0_OR_GREATER
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
|
|
||||||
@ -16,11 +17,7 @@ public static class TimeSpanExtensions
|
|||||||
/// A <see cref="DateTime" /> that is a duration of <paramref name="value" /> in the past relative to the current time.
|
/// A <see cref="DateTime" /> that is a duration of <paramref name="value" /> in the past relative to the current time.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTime Ago(this TimeSpan value)
|
public static DateTime Ago(this TimeSpan value)
|
||||||
{
|
{
|
||||||
return DateTime.Now.Subtract(value);
|
return DateTime.Now.Subtract(value);
|
||||||
@ -34,11 +31,7 @@ public static class TimeSpanExtensions
|
|||||||
/// A <see cref="DateTime" /> that is a duration of <paramref name="value" /> in the future relative to the current time.
|
/// A <see cref="DateTime" /> that is a duration of <paramref name="value" /> in the future relative to the current time.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTime FromNow(this TimeSpan value)
|
public static DateTime FromNow(this TimeSpan value)
|
||||||
{
|
{
|
||||||
return DateTime.Now.Add(value);
|
return DateTime.Now.Add(value);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
|
|
||||||
@ -24,11 +25,7 @@ public static class UInt16Extensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeMilliseconds(this ushort value)
|
public static DateTimeOffset FromUnixTimeMilliseconds(this ushort value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
||||||
@ -49,11 +46,7 @@ public static class UInt16Extensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeSeconds(this ushort value)
|
public static DateTimeOffset FromUnixTimeSeconds(this ushort value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeSeconds(value);
|
return DateTimeOffset.FromUnixTimeSeconds(value);
|
||||||
@ -68,11 +61,7 @@ public static class UInt16Extensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsLeapYear(this ushort value)
|
public static bool IsLeapYear(this ushort value)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
@ -89,11 +78,7 @@ public static class UInt16Extensions
|
|||||||
/// <param name="value">The duration, in ticks.</param>
|
/// <param name="value">The duration, in ticks.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Ticks(this ushort value)
|
public static TimeSpan Ticks(this ushort value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromTicks(value);
|
return TimeSpan.FromTicks(value);
|
||||||
@ -107,11 +92,7 @@ public static class UInt16Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Milliseconds(this ushort value)
|
public static TimeSpan Milliseconds(this ushort value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMilliseconds(value);
|
return TimeSpan.FromMilliseconds(value);
|
||||||
@ -125,11 +106,7 @@ public static class UInt16Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Seconds(this ushort value)
|
public static TimeSpan Seconds(this ushort value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromSeconds(value);
|
return TimeSpan.FromSeconds(value);
|
||||||
@ -143,11 +120,7 @@ public static class UInt16Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Minutes(this ushort value)
|
public static TimeSpan Minutes(this ushort value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMinutes(value);
|
return TimeSpan.FromMinutes(value);
|
||||||
@ -161,11 +134,7 @@ public static class UInt16Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Hours(this ushort value)
|
public static TimeSpan Hours(this ushort value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromHours(value);
|
return TimeSpan.FromHours(value);
|
||||||
@ -177,11 +146,7 @@ public static class UInt16Extensions
|
|||||||
/// <param name="value">The duration, in days.</param>
|
/// <param name="value">The duration, in days.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Days(this ushort value)
|
public static TimeSpan Days(this ushort value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value);
|
return TimeSpan.FromDays(value);
|
||||||
@ -195,11 +160,7 @@ public static class UInt16Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Weeks(this ushort value)
|
public static TimeSpan Weeks(this ushort value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value * 7);
|
return TimeSpan.FromDays(value * 7);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
|
|
||||||
@ -24,11 +25,7 @@ public static class UInt32Extensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeMilliseconds(this uint value)
|
public static DateTimeOffset FromUnixTimeMilliseconds(this uint value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
||||||
@ -49,11 +46,7 @@ public static class UInt32Extensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeSeconds(this uint value)
|
public static DateTimeOffset FromUnixTimeSeconds(this uint value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeSeconds(value);
|
return DateTimeOffset.FromUnixTimeSeconds(value);
|
||||||
@ -68,11 +61,7 @@ public static class UInt32Extensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsLeapYear(this uint value)
|
public static bool IsLeapYear(this uint value)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
@ -89,11 +78,7 @@ public static class UInt32Extensions
|
|||||||
/// <param name="value">The duration, in ticks.</param>
|
/// <param name="value">The duration, in ticks.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Ticks(this uint value)
|
public static TimeSpan Ticks(this uint value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromTicks(value);
|
return TimeSpan.FromTicks(value);
|
||||||
@ -107,11 +92,7 @@ public static class UInt32Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Milliseconds(this uint value)
|
public static TimeSpan Milliseconds(this uint value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMilliseconds(value);
|
return TimeSpan.FromMilliseconds(value);
|
||||||
@ -125,11 +106,7 @@ public static class UInt32Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Seconds(this uint value)
|
public static TimeSpan Seconds(this uint value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromSeconds(value);
|
return TimeSpan.FromSeconds(value);
|
||||||
@ -143,11 +120,7 @@ public static class UInt32Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Minutes(this uint value)
|
public static TimeSpan Minutes(this uint value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMinutes(value);
|
return TimeSpan.FromMinutes(value);
|
||||||
@ -161,11 +134,7 @@ public static class UInt32Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Hours(this uint value)
|
public static TimeSpan Hours(this uint value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromHours(value);
|
return TimeSpan.FromHours(value);
|
||||||
@ -177,11 +146,7 @@ public static class UInt32Extensions
|
|||||||
/// <param name="value">The duration, in days.</param>
|
/// <param name="value">The duration, in days.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Days(this uint value)
|
public static TimeSpan Days(this uint value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value);
|
return TimeSpan.FromDays(value);
|
||||||
@ -195,11 +160,7 @@ public static class UInt32Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Weeks(this uint value)
|
public static TimeSpan Weeks(this uint value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays(value * 7);
|
return TimeSpan.FromDays(value * 7);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using X10D.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Time;
|
namespace X10D.Time;
|
||||||
|
|
||||||
@ -24,11 +25,7 @@ public static class UInt64Extensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799,999.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeMilliseconds(this ulong value)
|
public static DateTimeOffset FromUnixTimeMilliseconds(this ulong value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeMilliseconds((long)value);
|
return DateTimeOffset.FromUnixTimeMilliseconds((long)value);
|
||||||
@ -49,11 +46,7 @@ public static class UInt64Extensions
|
|||||||
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
/// <para><paramref name="value" /> is greater than 253,402,300,799.</para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static DateTimeOffset FromUnixTimeSeconds(this ulong value)
|
public static DateTimeOffset FromUnixTimeSeconds(this ulong value)
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeSeconds((long)value);
|
return DateTimeOffset.FromUnixTimeSeconds((long)value);
|
||||||
@ -68,11 +61,7 @@ public static class UInt64Extensions
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is 0.</exception>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static bool IsLeapYear(this ulong value)
|
public static bool IsLeapYear(this ulong value)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
@ -89,11 +78,7 @@ public static class UInt64Extensions
|
|||||||
/// <param name="value">The duration, in ticks.</param>
|
/// <param name="value">The duration, in ticks.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.Ticks" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Ticks(this ulong value)
|
public static TimeSpan Ticks(this ulong value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromTicks((long)value);
|
return TimeSpan.FromTicks((long)value);
|
||||||
@ -107,11 +92,7 @@ public static class UInt64Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMilliseconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Milliseconds(this ulong value)
|
public static TimeSpan Milliseconds(this ulong value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMilliseconds((long)value);
|
return TimeSpan.FromMilliseconds((long)value);
|
||||||
@ -125,11 +106,7 @@ public static class UInt64Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalSeconds" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Seconds(this ulong value)
|
public static TimeSpan Seconds(this ulong value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromSeconds((long)value);
|
return TimeSpan.FromSeconds((long)value);
|
||||||
@ -143,11 +120,7 @@ public static class UInt64Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalMinutes" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Minutes(this ulong value)
|
public static TimeSpan Minutes(this ulong value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMinutes((long)value);
|
return TimeSpan.FromMinutes((long)value);
|
||||||
@ -161,11 +134,7 @@ public static class UInt64Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalHours" /> will equal <paramref name="value" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Hours(this ulong value)
|
public static TimeSpan Hours(this ulong value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromHours((long)value);
|
return TimeSpan.FromHours((long)value);
|
||||||
@ -177,11 +146,7 @@ public static class UInt64Extensions
|
|||||||
/// <param name="value">The duration, in days.</param>
|
/// <param name="value">The duration, in days.</param>
|
||||||
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
/// <returns>A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" />.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Days(this ulong value)
|
public static TimeSpan Days(this ulong value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays((long)value);
|
return TimeSpan.FromDays((long)value);
|
||||||
@ -195,11 +160,7 @@ public static class UInt64Extensions
|
|||||||
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
/// A <see cref="TimeSpan" /> whose <see cref="TimeSpan.TotalDays" /> will equal <paramref name="value" /> × 7.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
#if NETSTANDARD2_1
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
#else
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
#endif
|
|
||||||
public static TimeSpan Weeks(this ulong value)
|
public static TimeSpan Weeks(this ulong value)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromDays((long)value * 7);
|
return TimeSpan.FromDays((long)value * 7);
|
||||||
|
Loading…
Reference in New Issue
Block a user