bit calculation