1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-19 16:40:26 +02:00
Beef/BeefLibs/corlib/src/UInt8.bf

71 lines
1.3 KiB
Beef
Raw Normal View History

2019-08-23 11:56:54 -07:00
namespace System
{
2020-08-10 13:27:48 -07:00
#unwarn
struct UInt8 : uint8, IInteger, IUnsigned, IHashable, IFormattable, IIsNaN
2019-08-23 11:56:54 -07:00
{
public const uint8 MaxValue = (uint8)0xFF;
public const uint8 MinValue = 0;
public static int operator<=>(Self a, Self b)
{
return (SelfBase)a <=> (SelfBase)b;
}
public static Self operator+(Self lhs, Self rhs)
{
return (SelfBase)lhs + (SelfBase)rhs;
}
public static Self operator-(Self lhs, Self rhs)
{
return (SelfBase)lhs - (SelfBase)rhs;
}
2019-08-23 11:56:54 -07:00
public static Self operator-(Self value)
{
return (SelfBase)value;
}
public static Self operator*(Self lhs, Self rhs)
{
return (SelfBase)lhs * (SelfBase)rhs;
}
public static Self operator/(Self lhs, Self rhs)
{
return (SelfBase)lhs / (SelfBase)rhs;
}
2020-02-18 08:41:14 -08:00
public int GetHashCode()
2019-08-23 11:56:54 -07:00
{
return (int)this;
}
bool IIsNaN.IsNaN
{
[SkipCall]
get
{
return false;
}
}
2020-07-19 05:45:35 -07:00
public override void ToString(String outString)
{
((uint32)this).ToString(outString);
}
2019-08-23 11:56:54 -07:00
public void ToString(String outString, String format, IFormatProvider formatProvider)
{
if(format == null || format.IsEmpty)
2019-08-23 11:56:54 -07:00
{
ToString(outString);
}
else
{
NumberFormatter.NumberToString(format, (uint32)this, formatProvider, outString);
2019-08-23 11:56:54 -07:00
}
}
}
}