That hapepns because of the operation priorities. It executes | at first, and then ==. Add brackets to change it.
Answered
Bitwise operation does not work as expected
I found a strange behavior in func bitwise operation. I don't understand why.
slice slice0 = begin_cell().store_coins(123).end_cell().begin_parse();
int result0 = 0 == 1;
~dump(result0); ;; this is 0
int result1 = equal_slices(slice0, slice0);
~dump(result1); ;; this is -1
~dump(result0 | result1); ;; this is -1, as expected
In above code, OR operation is working as expected. However, it does not in below code.
~dump(0 == 1); ;; this is 0
~dump(equal_slices(slice0, slice0)); ;; this is -1
~dump(0 == 1 | equal_slices(slice0, slice0)); ;; this is 0. Why?
14K Views
2
Answers
one year ago
one year ago
Tags