← Back to index
|
Original Bugzilla link
Bug 7268 – Incorrect sign when raising negative number to even power.
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2012-01-10T21:58:00Z
Last change time
2012-01-12T23:07:56Z
Assigned to
nobody
Creator
mail.mantis.88
Comments
Comment #0
by mail.mantis.88 — 2012-01-10T21:58:58Z
dmd 2.057, windows Raising negative number to even power results in a negative number, e.g.: static assert( (-10 ^^ 2) != (-10 * -10) ); //pass static assert( (-10 ^^ 2) == (-10 * -10) ); //Error: static assert (-100 == 100) is false
Comment #1
by k.hara.pg — 2012-01-12T23:07:56Z
This is correct.
http://d-programming-language.org/expression.html#UnaryExpression
From priority of operators, (-10 ^^ 2) is translated to (-(10^^2)), so the result is -(100) == -100.