bits

Are You Odd?

Occasionally the needs arises to determine if a number is odd or even. Why would you need to do this? One example is the 'striping' of output, where information is presented in rows, and alternating rows have a different background color, like this:

Row1
Row2
Row3



You would think that languages would all have a function for this by now, but just as determining whether a year is a leap year is often still up to the programmer, so too is whether a number is odd or even.

Subscribe to RSS - bits
©2005-2017 Ayen Designs. Underlying theme by Kiwi Themes.