• NullPointer
    link
    910 months ago

    here is somewhat less:

    return (number % 2) == 0;

      • MuchPineapples
        link
        fedilink
        8
        edit-2
        10 months ago

        This is the way. Modulo takes too long to compute, bitwise compare should be a lot faster.

        return !(number & 0x1);
        
    • huf [he/him]
      link
      fedilink
      English
      410 months ago

      just check the last bit jesus christ, what is it with these expensive modulo operations?!

      return !(n&1);