Closed as not planned
Description
Background and motivation
When having to initialize T : INumberBase<T>
to some default values, theres T.Zero
and T.One
, but not min and max values.
Unless I'm missing the existence of an interface that has them, maybe INumberBase<T>
is a good one to add it.
API Proposal
namespace System.Numerics;
public interface INumberBase<TSelf>
{
static abstract TSelf MinValue { get; }
static abstract TSelf MaxValue { get; }
}
API Usage
internal sealed class SPSAAttribute<T> : Attribute
where T : INumberBase<T>, IMultiplyOperators<T, T, T>, IConvertible, IParsable<T>, ISpanParsable<T>, IDivisionOperators<T, T, T>
{
public T MinValue { get; }
public T MaxValue { get; }
SPSAAttribute()
{
MinValue = T.MinValue;
MaxValue = T.MaxValue;
}
}
Alternative Designs
No response
Risks
No response