Quote:
Originally Posted by salesman
You're missing an operation in the isEven() function!
The way I usually look at it, checking if its even by int(x / 2) == (x / 2) requires four basic operations (int, 2 divides, and a comparison), at least two references (x twice, maybe a third for the int() function call). Modulus requires two basic operations (mod, and a comparison) and only one variable reference.
But yeah I agree, the difference is so small it probably wouldn't matter in most cases.
|
As a wise man once told me: "This isn't NASA." It's kind of ironic how often such a stupid sounding saying like that applies.
