Optical endoder gives two steps

Lots of encoders do that. The mechanical clicker has half as many steps as the electrical side. You may find that it always stops in a position where outputA is always HIGH.

Some encoders have a 1:4 ratio so they always stop with both outputs high.

The division operator is the forward-slash.

int realPosition = counter/2;