/// <summary> /// Subtracts one Fixed number from another /// </summary> /// <param name="other"> /// Number to be subtracted from caller /// </param> /// <returns> /// New Fixed<T> instance with the subtracted value /// </returns> public Fixed <T> Subtract(Fixed <T> other) { return(new Fixed <T> { value = this.value - other.value }); }
public Fixed <T> Divide(Fixed <T> q) { return(new Fixed <T>(precision.Divide(fixedPointNumber, q.fixedPointNumber), true)); }
/// <summary> /// Adds two Fixed numbers of the same type together /// </summary> /// <param name="other"> /// Number to be added to caller /// </param> /// <returns> /// New Fixed<T> instance with the added value /// </returns> public Fixed <T> Add(Fixed <T> other) { return(new Fixed <T> { value = this.value + other.value }); }
public Fixed <T> Subtract(Fixed <T> q) { return(new Fixed <T>(precision.Subtract(fixedPointNumber, q.fixedPointNumber), true)); }
public Fixed <T> Multiply(Fixed <T> q) { return(new Fixed <T>(precision.Multiply(fixedPointNumber, q.fixedPointNumber), true)); }
public Fixed <T> DivideWithoutLong(Fixed <T> f) => new Fixed <T>((int)(((long)this.Value << LowerBits) / f.Value), change: false);
public Fixed <T> Add(Fixed <T> q) { return(new Fixed <T>(precision.Add(fixedPointNumber, q.fixedPointNumber), true)); }
public Fixed <T> MultiplyWithoutLong(Fixed <T> f) => new Fixed <T>((int)(((long)this.Value * f.Value) >> LowerBits), change: false);
public Fixed <T> Divide(Fixed <T> f) => new Fixed <T>(((long)this.Value << LowerBits) / f.Value);
public Fixed <T> Multiply(Fixed <T> f) => new Fixed <T>(((long)this.Value * f.Value) >> LowerBits);
public Fixed <T> SubtractWithoutLong(Fixed <T> f) => new Fixed <T>(this.Value - f.Value, change: false);
public Fixed <T> Subtract(Fixed <T> f) => new Fixed <T>((long)this.Value - f.Value);
public Fixed <T> AddWithoutLong(Fixed <T> f) => new Fixed <T>(this.Value + f.Value, change: false);
public Fixed <T> Add(Fixed <T> f) => new Fixed <T>((long)this.Value + f.Value);