It’s only the wrong solution if you’re writing something where every operation needs to be accounted for. Modulo is a great, easy, readable method otherwise.
Not too certain on C++, but I think this would be the cleanest implementation that still somewhat optimizes itself:
It’s only the wrong solution if you’re writing something where every operation needs to be accounted for. Modulo is a great, easy, readable method otherwise.
Not too certain on C++, but I think this would be the cleanest implementation that still somewhat optimizes itself:
private bool IsEven(int number){ return !(number % 2) }