mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Add ability to get min/max values for generic floating point
This commit is contained in:
parent
484b9716db
commit
af7ca28707
3 changed files with 23 additions and 2 deletions
|
@ -10,11 +10,14 @@ namespace System
|
|||
using System.Diagnostics;
|
||||
|
||||
#unwarn
|
||||
public struct Double : double, IFloating, ISigned, IFormattable, IHashable, ICanBeNaN, IParseable<double>
|
||||
public struct Double : double, IFloating, ISigned, IFormattable, IHashable, ICanBeNaN, IParseable<double>, IMinMaxValue<double>
|
||||
{
|
||||
public const double MinValue = -1.7976931348623157E+308;
|
||||
public const double MaxValue = 1.7976931348623157E+308;
|
||||
|
||||
public static double IMinMaxValue<double>.MinValue => MinValue;
|
||||
public static double IMinMaxValue<double>.MaxValue => MaxValue;
|
||||
|
||||
// Note Epsilon should be a double whose hex representation is 0x1
|
||||
// on little endian machines.
|
||||
public const double Epsilon = 4.9406564584124654E-324;
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Globalization;
|
|||
namespace System
|
||||
{
|
||||
#unwarn
|
||||
struct Float : float, IFloating, ISigned, IFormattable, IHashable, IEquatable<float>, ICanBeNaN, IParseable<float>
|
||||
struct Float : float, IFloating, ISigned, IFormattable, IHashable, IEquatable<float>, ICanBeNaN, IParseable<float>, IMinMaxValue<float>
|
||||
{
|
||||
public const float MinValue = (float)-3.40282346638528859e+38;
|
||||
public const float Epsilon = (float)1.4e-45;
|
||||
|
@ -12,6 +12,9 @@ namespace System
|
|||
public const float NegativeInfinity = -1.0f / 0.0f;
|
||||
public const float NaN = 0.0f / 0.0f;
|
||||
|
||||
public static float IMinMaxValue<float>.MinValue => MinValue;
|
||||
public static float IMinMaxValue<float>.MaxValue => MaxValue;
|
||||
|
||||
// We use this explicit definition to avoid the confusion between 0.0 and -0.0.
|
||||
public const float NegativeZero = (float)-0.0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue