asik / FixedMath.Net

Fixed point math C# library
Other
591 stars 126 forks source link

Function Pow bug report #17

Open yunsile321 opened 6 years ago

yunsile321 commented 6 years ago

public static Fix64 Pow(Fix64 b, Fix64 exp) if b is negative, Log2 will Throw exception. bool isNeg = false; if (b.m_rawValue < 0) { isNeg = true; } Fix64 log2 = isNeg ? Log2(-b) : Log2(b);

asik commented 6 years ago

Well at least it's documented :P

/// <exception cref="ArgumentOutOfRangeException">
/// The base was negative, with a non-zero exponent
/// </exception>

And the tests even validate that behavior. Which obviously is incorrect. It would be easy to implement by identity (a^-b = 1 / a^b), but fixing the test is more tricky. The way significant digits are validated right now is not clean.