The use of the Nat (unsigned) primitive makes subtraction dangerous. Even if a + b > c, the expression
might see an underflow (because b < c, and ergo b-c underflows) and an erroneous result.
A simple caution is to group (and perform first) addition, i.e.
An example of such expressions occur when calculating whether the target qubit lies in the prefix qubit subsets (see densitymatrix_oneQubitDepolarising()).
The use of the
Nat(unsigned) primitive makes subtraction dangerous. Even ifa + b > c, the expressionmight see an underflow (because
b < c, and ergob-cunderflows) and an erroneous result.A simple caution is to group (and perform first) addition, i.e.
An example of such expressions occur when calculating whether the target qubit lies in the prefix qubit subsets (see
densitymatrix_oneQubitDepolarising()).