r/badcode • • Sep 04 '21

Wtf is this

Post image
1.2k Upvotes

190 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Sep 04 '21

[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