Is there a way without using logic and bitwise operators, just arithmetic operators, to flip between integers with the value 0 and 1?
ie. variable ?= variable
will make the variable 1 if it 0 or 0 if it is 1.
The string concatenation operator (&) is not an arithmetic operator, but in precedence, it does fall after all arithmetic operators and before all comparison operators.
Definition. The arithmetic operators perform addition, subtraction, multiplication, division, exponentiation, and modulus operations.
These operators are + (addition), - (subtraction), * (multiplication), / (division), and % (modulo).
x = 1 - x
Will switch between 0 and 1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With