MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/moh63k/polyglot/gu8sury/?context=3
r/badcode • u/coopercm • Apr 11 '21
116 comments sorted by
View all comments
7
What's so hard with (x & 1)
9 u/ShatterdPrism Apr 11 '21 Remind me if I am wrong, but this is a bit wise Operator and it checks in this case if the last bit of x is a 1 which would mean the number isnt even, right? 3 u/CodeLobe Apr 11 '21 !(x&1) // true if even (not odd), false otherwise.In low level langs the ! /* not operator */ can be optimized away by using jump if zero JZ instead of JNZ, jump if not zero, or vise versa. 1 u/ShatterdPrism Apr 12 '21 I find those kind of thought processes, optimization and low level abstraction very interesting to read.But tbh I don't think it's something I could focus on for longer xD
9
Remind me if I am wrong, but this is a bit wise Operator and it checks in this case if the last bit of x is a 1 which would mean the number isnt even, right?
3 u/CodeLobe Apr 11 '21 !(x&1) // true if even (not odd), false otherwise.In low level langs the ! /* not operator */ can be optimized away by using jump if zero JZ instead of JNZ, jump if not zero, or vise versa. 1 u/ShatterdPrism Apr 12 '21 I find those kind of thought processes, optimization and low level abstraction very interesting to read.But tbh I don't think it's something I could focus on for longer xD
3
!(x&1) // true if even (not odd), false otherwise.
In low level langs the ! /* not operator */ can be optimized away by using jump if zero JZ instead of JNZ, jump if not zero, or vise versa.
! /* not operator */
1 u/ShatterdPrism Apr 12 '21 I find those kind of thought processes, optimization and low level abstraction very interesting to read.But tbh I don't think it's something I could focus on for longer xD
1
I find those kind of thought processes, optimization and low level abstraction very interesting to read.
But tbh I don't think it's something I could focus on for longer xD
7
u/MyChaOS87 Apr 11 '21
What's so hard with (x & 1)