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
{{ message }}
Repository navigation
Pow(-1, n) throws OverflowException for any integer |n| ≥ 2^31, although the result is ±1 #128
The integer-power path in Pow (PreciseNumber/PreciseNumber.cs:1818) loops over power.Abs().To<int>(), so an exponent that doesn't fit in an int throws. IsUnit already short-circuits a base of +1, but a base of −1 gets no such shortcut, even though (−1)^n is always ±1.
Priority: Low. It is an edge case (base −1 with an exponent of at least 2^31) and fails loudly with OverflowException rather than returning a wrong value.
Area / suggested owner: Integer-power path in PreciseNumber.Pow
Activity
matt-edmondson commentedon Sep 27, 2026
Triage
OverflowExceptionrather than returning a wrong value.PreciseNumber.PowPow.IsUnitcheck. A fix for Pow with a fractional exponent misrounds the last digit: Pow(19, 1.5) ends in …417 instead of …416 (double rounding without guard digits) #127 (also inPow) could carry it, as long as both keep their own tests.Generated by Claude Code