Re:Math.Pow(-1, 2) == -1 in Windows 11 Insider build
by The_suffocated on Wednesday July 02, 2025 @08:58AM
(#44443200)
No idea why this happened. Perhaps Math.Pow(x,y) was implemented as 2**(y*log2(x)) without writing special code to deal with the case where x is negative real and y is integer?
[ Parent
| on HN ]
Re:Math.Pow(-1, 2) == -1 in Windows 11 Insider build
by rich_sasha on Wednesday July 02, 2025 @09:40AM
(#44443625)
In fairness, the general power function might well be complicated. Dealing with fractional base and exponent, signs (-1^2 makes sense but -1^0.5 doesn't in real numbers). I don't know how that works in code but I can see how this gremlin sneaks in.
I don't see how it gets past the test suite though.