Well, since kTwo is a constant with zero assigned to it, the (kZero > 0) clause will always be false. Thus, kTwo will always be assigned 0. Just set it to zero and the problem will probably go away ...