Conversion to or from thermometric code