Renormalization-group treatment of the critical dynamics of the binary-fluid and gas-liquid transitions