Hacker News new | ask | show | jobs
by ChrisMarshallNY 523 days ago
When I wrote in ASM, I always used to look at the LSB (Least Significant Bit). If it was zero, then the number was even.

Things are probably different, these days, so maybe that isn’t effective.

1 comments

Just to add some closure. This is how I'd do it in Swift:

    extension FixedWidthInteger { var isEven: Bool { 0 == 1 & self } }