Refactored hp_to_double()