You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SignificantNumber.Pow (SignificantNumber/SignificantNumber.cs, ~line 579) sets the result precision with LowestSignificantDigits(this, power). An integer exponent such as 2 or 3 has 1 significant digit, and only -1, 0 and 1 are treated as exact, so the result is rounded to 1 significant digit. Exp has the same problem (~line 602).
This is separate from #101, which covers the lost sign of a negative base. The precision loss happens for positive bases too.
Expression
Returned
Expected
1.234.Pow(2)
2
1.523 (as 1.234 * 1.234 returns)
(-2.5).Pow(3)
20
about -15.6 (sign is #101; the magnitude also collapses to 1 digit)
SignificantNumber.Exp(2)
7
more than 1 significant digit
Reproduced against the current main build.
Why it matters
x.Pow(2) and x * x should agree, but they differ by up to an order of magnitude in reported precision. Any formula using squares or cubes (areas, volumes, kinetic energy, variance) silently collapses to one significant digit, which defeats the purpose of a significant-figures type.
Suggested fix
Treat an integer exponent as exact, like the counting numbers in a multiplication. The result should keep the base's significant digits, which matches the behaviour of repeated multiplication.
Apply the same rule to Exp: its precision should come from the exponent's value, not collapse to 1 digit for an integer input.
What's wrong
SignificantNumber.Pow(SignificantNumber/SignificantNumber.cs, ~line 579) sets the result precision withLowestSignificantDigits(this, power). An integer exponent such as2or3has 1 significant digit, and only -1, 0 and 1 are treated as exact, so the result is rounded to 1 significant digit.Exphas the same problem (~line 602).This is separate from #101, which covers the lost sign of a negative base. The precision loss happens for positive bases too.
1.234.Pow(2)21.523(as1.234 * 1.234returns)(-2.5).Pow(3)20-15.6(sign is #101; the magnitude also collapses to 1 digit)SignificantNumber.Exp(2)7Reproduced against the current
mainbuild.Why it matters
x.Pow(2)andx * xshould agree, but they differ by up to an order of magnitude in reported precision. Any formula using squares or cubes (areas, volumes, kinetic energy, variance) silently collapses to one significant digit, which defeats the purpose of a significant-figures type.Suggested fix
Exp: its precision should come from the exponent's value, not collapse to 1 digit for an integer input.BigInteger) rather thanExp(Log(|x|) * p). That also keeps the sign, which would let this land together with the Pow returns a positive result for a negative base: (-2)^3 == 8, (-1)^3 == 1 #101 fix.Acceptance criteria
1.234.Pow(2) == 1.234 * 1.234.Exp(2)returns more than 1 significant digit.