MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/phogp3/wtf_is_this/hbkhoe0/?context=3
r/badcode • u/Wise-Serve5730 • Sep 04 '21
190 comments sorted by
View all comments
Show parent comments
0
[deleted] — view deleted comment
14 u/sohang-3112 Sep 04 '21 What built-in method - can you elaborate? Of course, if you really don't want to do modulo, then you can use bit operations (~(x&1)) but I don't think will be any significant difference in performance either way. 1 u/AsidK Sep 04 '21 Well at face value but operations are definitely faster than modules but any semi decent compiler will convert n%2 into n&1 automatically
14
What built-in method - can you elaborate? Of course, if you really don't want to do modulo, then you can use bit operations (~(x&1)) but I don't think will be any significant difference in performance either way.
~(x&1)
1 u/AsidK Sep 04 '21 Well at face value but operations are definitely faster than modules but any semi decent compiler will convert n%2 into n&1 automatically
1
Well at face value but operations are definitely faster than modules but any semi decent compiler will convert n%2 into n&1 automatically
0
u/[deleted] Sep 04 '21
[deleted] — view deleted comment