dimanche 31 juillet 2016

What is most optimal way to replace integer '0' with '1' in c++

I have a piece of code where I multiply two numbers but condition is none of those integer numbers should be 0. If it is 0, I need to make it to 1 so that it is not counted.

y=x*z // x>0, z>0. if x==0 then x=1, if z==0, then z=1;

I want to avoid "if" condition check on every variable and replace with 1. Is there a better way of doing it.

Aucun commentaire:

Enregistrer un commentaire