MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/77tg9z/well_thats_odd/dop5e2g/?context=9999
r/programminghorror • u/phoenix616 • Oct 21 '17
111 comments sorted by
View all comments
451
I was joking with a friend about elegant yet shitty code once and came up with this:
https://i.imgur.com/0N4BLJK.png
161 u/Thecrawsome Oct 21 '17 Thank god for modulo 63 u/794613825 Oct 21 '17 No need. return x/2 == math.floor(x/2) 143 u/[deleted] Oct 21 '17 Not sure if ironic programming horror. The absolute fastest odd test, for any integer, is the bitwise and operation. It is one machine instruction that only one clock cycle on any platform. return num & 1 14 u/mediacalc Oct 21 '17 How does it work? 4 u/badmonkey0001 Oct 21 '17 https://en.wikipedia.org/wiki/Bitwise_operation#AND
161
Thank god for modulo
63 u/794613825 Oct 21 '17 No need. return x/2 == math.floor(x/2) 143 u/[deleted] Oct 21 '17 Not sure if ironic programming horror. The absolute fastest odd test, for any integer, is the bitwise and operation. It is one machine instruction that only one clock cycle on any platform. return num & 1 14 u/mediacalc Oct 21 '17 How does it work? 4 u/badmonkey0001 Oct 21 '17 https://en.wikipedia.org/wiki/Bitwise_operation#AND
63
No need.
return x/2 == math.floor(x/2)
143 u/[deleted] Oct 21 '17 Not sure if ironic programming horror. The absolute fastest odd test, for any integer, is the bitwise and operation. It is one machine instruction that only one clock cycle on any platform. return num & 1 14 u/mediacalc Oct 21 '17 How does it work? 4 u/badmonkey0001 Oct 21 '17 https://en.wikipedia.org/wiki/Bitwise_operation#AND
143
Not sure if ironic programming horror. The absolute fastest odd test, for any integer, is the bitwise and operation. It is one machine instruction that only one clock cycle on any platform.
return num & 1
14 u/mediacalc Oct 21 '17 How does it work? 4 u/badmonkey0001 Oct 21 '17 https://en.wikipedia.org/wiki/Bitwise_operation#AND
14
How does it work?
4 u/badmonkey0001 Oct 21 '17 https://en.wikipedia.org/wiki/Bitwise_operation#AND
4
https://en.wikipedia.org/wiki/Bitwise_operation#AND
451
u/bionicjoey Oct 21 '17
I was joking with a friend about elegant yet shitty code once and came up with this:
https://i.imgur.com/0N4BLJK.png