• droans@lemmy.world
    link
    fedilink
    arrow-up
    6
    arrow-down
    1
    ·
    1 year ago

    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)
    }