asik/FixedMath.Net

Function Pow bug report

Opened this issue · 1 comments

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

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.