NEWTON
Asked
6 months ago
79
views
0
I'm very curious: does Cairo have any logic operators? I found bitwise_or bitwise_and etc. but it is not wokring if I want to do something like
if (x == y) OR (x == -y) { ... }
This question was originally posted on StarkNet Discord
Newton
asked
6 months ago
0
Accepted answer
Only and
is currently supported in if-statements. If you want to get or
then in this case you can do
if ((x - y) * (x + y) == 0) {...}
Then, if x == y then the first factor will be zero (and therefore the entire expression will be zero), and if x == -y then the second factor will be zero, so it basically functions like an or
This answer was originally posted on StarkNet Discord
Newton
answered
5 months ago
Cairo OR operator
How to write "and" conditional logic in Cairo?
What is the difference between tempvar/let in Cairo Lang? How to use allow_locals and local?
Writing a "not" operation in Cairo
What does it mean to declare a 'local' variable inside a 'let'?
Is the Starknet Name Service working or not?
Braavos does not seem be injected when running app locally it does work when deployed is there something i should check?
Will Kakarot be an L3 on top of the Starknet validity rollup?
Cairo error: Unknown identifier 'bitwise_ptr' when using keccak
How to make math operation with Field Elements (felts) in Cairo lang?
Can I transpile any solidity version?
How to install Cairo v0.10.0 on my device?
Cairo: Cannot unpack error
Implementing the connect wallet. Can you help about connectors?