14.06.2011, 13:46
Quote:
OK, here are 2 suggestions for better efficiency:
1) The round up thing has always 1 cells which is never used. Did not think far enough before: This would be better: pawn Код:
(30 + 2) / 2 = 16, while you actually only want 15 cells. 1 cell to much. (31 + 2) / 2 = 16, here you actually want 16 cells. Now better: (30 + 1) / 2 = 15, exactly what you wanted, 15 cells. (31 + 1) / 2 = 16, here you actually want 16 cells. 2) For speed: Instead of using / 2, you could use >>> 1 and you get the same result. Division is probably slower than shifting. (However, I'm not sure about this.) |