4 ms·
x <= y isn't two tests. In a low-level sense, branch-if-greater-or-equal is one instruction even on RISC machines — and not one any more "complex" than branch-
by derefr 3y ago
x <= y isn't two tests.
In a low-level sense, branch-if-greater-or-equal is one instruction even on RISC machines — and not one any more "complex" than branch-if-greater.
In an abstract boolean-algebra sense, x <= y is the same as !(x > y).
- zabzonk 3y ago> x <= y is the same as !(x > y) i.e. two tests, or perhaps i should say logical operations. i'm not saying don't use '<=', but do check that it is doing what you think it should.
- derefr 3y agoLet me put it another way: the following are the same code: if: x <= y, do: foo(), else: nothing() if: y < x, do: nothing(), else: foo()
- AugurCognito 3y agoShouldn't the last statement be: if: y > x, do: nothing(), else: foo()
- rurban 3y agoNope, order of evaluation might matter with impure code.
- rowanG077 3y agoHow exactly? Well there is an extreme case where x and y are volatile but even then the order is implementation defined so I can't see a world where it matters.
- deleted 3y ago[deleted]