add Fix64-int arithmetic

custom_video_shaders
cosmonaut 2022-08-16 18:24:34 -07:00
parent 49f852a822
commit a427b79510
1 changed files with 50 additions and 0 deletions

View File

@ -531,6 +531,16 @@ namespace MoonWorks.Math.Fixed
return new Fix64(sum); return new Fix64(sum);
} }
public static Fix64 operator +(Fix64 x, int y)
{
return x + new Fix64(y);
}
public static Fix64 operator +(int x, Fix64 y)
{
return new Fix64(x) + y;
}
public static Fix64 operator -(Fix64 x, Fix64 y) public static Fix64 operator -(Fix64 x, Fix64 y)
{ {
var xl = x.RawValue; var xl = x.RawValue;
@ -544,6 +554,16 @@ namespace MoonWorks.Math.Fixed
return new Fix64(diff); return new Fix64(diff);
} }
public static Fix64 operator -(Fix64 x, int y)
{
return x - new Fix64(y);
}
public static Fix64 operator -(int x, Fix64 y)
{
return new Fix64(x) - y;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Fix64 FastSub(Fix64 x, Fix64 y) private static Fix64 FastSub(Fix64 x, Fix64 y)
{ {
@ -668,6 +688,16 @@ namespace MoonWorks.Math.Fixed
return result; return result;
} }
public static Fix64 operator *(Fix64 x, int y)
{
return x * new Fix64(y);
}
public static Fix64 operator *(int x, Fix64 y)
{
return new Fix64(x) * y;
}
public static Fix64 operator /(Fix64 x, Fix64 y) public static Fix64 operator /(Fix64 x, Fix64 y)
{ {
var xl = x.RawValue; var xl = x.RawValue;
@ -726,6 +756,16 @@ namespace MoonWorks.Math.Fixed
return new Fix64(result); return new Fix64(result);
} }
public static Fix64 operator /(Fix64 x, int y)
{
return x / new Fix64(y);
}
public static Fix64 operator /(int x, Fix64 y)
{
return new Fix64(x) / y;
}
public static Fix64 operator %(Fix64 x, Fix64 y) public static Fix64 operator %(Fix64 x, Fix64 y)
{ {
return new Fix64( return new Fix64(
@ -734,6 +774,16 @@ namespace MoonWorks.Math.Fixed
x.RawValue % y.RawValue); x.RawValue % y.RawValue);
} }
public static Fix64 operator %(Fix64 x, int y)
{
return x % new Fix64(y);
}
public static Fix64 operator %(int x, Fix64 y)
{
return new Fix64(x) % y;
}
public static Fix64 operator -(Fix64 x) public static Fix64 operator -(Fix64 x)
{ {
return x.RawValue == MIN_VALUE ? MaxValue : new Fix64(-x.RawValue); return x.RawValue == MIN_VALUE ? MaxValue : new Fix64(-x.RawValue);