How are earnings calculated?