Unify compute_mg_value() and compute_eg_value()