public int Divide(Q32 other) { bool isResultNegative = (this.RawLongValue < 0) ^ (other.RawLongValue < 0); long num = (Math.Abs(RawLongValue) << FractionLength) / Math.Abs(other.RawLongValue); int result = (int)num; if (isResultNegative) { result *= -1; } return(result); }
public int Multilpy(Q32 other) { bool isResultNegative = (this.RawLongValue < 0) ^ (other.RawLongValue < 0); long num = Math.Abs(RawLongValue) * Math.Abs(other.RawLongValue); int result = (int)(num >> FractionLength); if (isResultNegative) { result *= -1; } return(result); }
public int Divide(Q32 a) { long num = (this.RawLongValue << FractionLength) / a.RawLongValue; // Divisor is greater than Dividened OR result is lower than zero if (this.RawLongValue == a.RawLongValue || this.RawLongValue == -a.RawLongValue) { return((int)num); } if (a.RawLongValue > this.RawLongValue || num < 0 << FractionLength) { int positiveOne = 1 << FractionLength; num += positiveOne; } return((int)num); }
internal Fixed(Q32 fixedPoint) { FixedPoint = fixedPoint; }
public int Subtract(Q32 other) { long num = this.RawLongValue - other.RawLongValue; return((int)num); }
public int Add(Q32 other) { long num = this.RawLongValue + other.RawLongValue; return((int)num); }
public int Subtract(Q32 a) { long num = this.RawLongValue - a.RawLongValue; return((int)num); }
public int Add(Q32 a) { long num = this.RawLongValue + a.RawLongValue; return((int)num); }
public int Multilpy(Q32 a) { long num = this.RawLongValue * a.RawLongValue; return((int)(num >> FractionLength)); }