You should precalcultate everything you can, unless it involves just additions and bit operations.