Thread: Prelude
View Single Post
  #10  
Old 12-18-2010, 10:34 PM
Cloven Cloven is offline
Delteria
Cloven's Avatar
Join Date: Dec 2006
Location: Florida, United States
Posts: 542
Cloven has a spectacular aura about
Send a message via AIM to Cloven
Quote:
Originally Posted by salesman View Post
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.
Reply With Quote