Calculating differences and absolute values