Two methods for finding a sprite in sprite sheet C++, which is better?
I prefer the first one, because having the named variable numRows:


Certainly makes the code more "self-documenting": it's easier for me (the programmer) to understand what the algorithm is doing
May make the code faster: because you only do the floor(imageWidth / SpriteAverageSize) calculation once instead of three times (although it's possible that an optimizing compiler might be able to make that optimization itself, even without your 'hint' that it's a reused sub-expression)