This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
Multi bitwise *XOR* and power operations in an expression get misleading results #1450
Labels
bug
Something isn't working
Describe the bug
The details of precedence can be found in page https://docs.microsoft.com/zh-cn/azure/quantum/user-guide/language/expressions/precedenceandassociativity.
It is shown that bitwise XOR has a higher priority than power operator,so we derived the following two formulas,but the result are confusing.
When calculate the expression
(~~~(~~~ 2)) ^ 3
, the order should be~~~ 2 = -3
,~~~ (-3) = 2
,2 ^ 3 = 8
.But the actual order is~~~ 2 = -3
,(-3) ^ 3 = -27
,~~~ (-27) = 26
.When calculate the expression
(~~~(~~~ 2 ^ 3))
,the order should be~~~ 2 = -3
,(-3) ^ 3 = -27
,~~~ (-27) = 26
.But the actual order is2 ^ 3 = 8
,~~~ 8 = -9
,~~~ (-9) = 8
.To Reproduce
Expected behavior
The result of first expression should be 8,and the second should be 26.
System information
operating system:
Windows 10dotnet version:
6.0.300QDK:
v0.24.210930The text was updated successfully, but these errors were encountered: