DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="5.1.0" />

 Number

public static class Number
Represents Generic Math extensions.
public static TResult FromBits<TResult>(this ReadOnlySpan<bool> bits) where TResult : struct, IBinaryInteger<TResult>

Converts bit vector to a value of type TResult.

public static void GetBits<T>(this T value, Span<bool> bits) where T : ValueType modreq(System.Runtime.InteropServices.UnmanagedType), IBinaryInteger<T>

Converts a value to a set of bits.

public static int GetMaxByteCount<T>() where T : IBinaryInteger<T>

Gets maximum number of bytes that can be used by T type when encoded in little-endian or big-endian format.

public static bool IsSigned<T>() where T : INumberBase<T>

Determines whether the specified numeric type is signed.

public static TOutput Normalize<TInput, TOutput>(this TInput value, TInput min, TInput max) where TInput : struct, INumberBase<TInput>, IComparisonOperators<TInput, TInput, bool> where TOutput : struct, IFloatingPoint<TOutput>

Normalizes value in the specified range.

public static double Normalize(this ulong value)

Normalizes 64-bit unsigned integer to interval [0..1).

public static double Normalize(this long value)

Normalizes 64-bit signed integer to interval [0..1).

public static float Normalize(this uint value)

Normalizes 32-bit unsigned integer to interval [0..1).

public static float Normalize(this int value)

Normalizes 32-bit signed integer to interval [0..1).