Question: how oxidation state is calculated?
Answer: The oxidation number of each atom can be calculated by subtracting the sum of lone pairs and electrons it gains from bonds from the number of valence electrons. Bonds between atoms of the same element (homonuclear bonds) are always divided equally.