error de decimalFormat.format ()

La statement de formatting decimal es la siguiente:

private var decimalFormat: DecimalFormat? = null decimalFormat = DecimalFormat("#.##########") 

Los valores que se deben pasar al método format () son:

 private var valueOne= java.lang.Double.NaN private var valueTwo: Double = 0.toDouble() 

Estoy tratando de hacer una aplicación de calculadora, y el error que obtengo se encuentra en los botones del operador cuando paso valueOne al método de formatting () :

  binding!!.buttonAdd.setOnClickListener { computeCalculation() CURRENT_ACTION = ADDITION binding!!.infoTextView.setText(decimalFormat.format(valueOne) + "+") binding!!.editText.setText(null) } binding!!.buttonSubtract.setOnClickListener { computeCalculation() CURRENT_ACTION = SUBTRACTION binding!!.infoTextView.setText(decimalFormat.format(valueOne) + "-") binding!!.editText.setText(null) } binding!!.buttonMultiply.setOnClickListener { computeCalculation() CURRENT_ACTION = MULTIPLICATION binding!!.infoTextView.setText(decimalFormat.format(valueOne) + "*") binding!!.editText.setText(null) } binding!!.buttonDivide.setOnClickListener { computeCalculation() CURRENT_ACTION = DIVISION binding!!.infoTextView.setText(decimalFormat.format(valueOne) + "/") binding!!.editText.setText(null) } binding!!.buttonEqual.setOnClickListener { computeCalculation() binding!!.infoTextView.text = binding!!.infoTextView.text.toString() + decimalFormat.format(valueTwo) + " = " + decimalFormat.format(valueOne) valueOne = java.lang.Double.NaN CURRENT_ACTION = '0' } 

El error que obtengo es:

 None of the following functions can be called with the arguments supplied: public final fun format(obj: Any!): String! defined in java.text.DecimalFormat public final fun format(number: Double): String! defined in java.text.DecimalFormat public final fun format(number: Long): String! defined in java.text.DecimalFormat 

El código completo para el método onCreate () se da a continuación:

 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = DataBindingUtil.setContentView<ActivityMainBinding>(this, R.layout.activity_main) decimalFormat = DecimalFormat("#.##########") binding?.buttonDot?.setOnClickListener { binding?.editText?.setText((binding as ActivityMainBinding).editText.text.toString() + ".") } binding?.buttonZero?.setOnClickListener { binding?.editText?.setText((binding as ActivityMainBinding).editText.text.toString() + "0") } binding?.buttonOne?.setOnClickListener { binding?.editText?.setText((binding as ActivityMainBinding).editText.text.toString() + "1") } binding?.buttonTwo?.setOnClickListener { binding?.editText?.setText((binding as ActivityMainBinding).editText.text.toString() + "2") } binding?.buttonThree?.setOnClickListener { binding?.editText?.setText((binding as ActivityMainBinding).editText.text.toString() + "3") } binding?.buttonFour?.setOnClickListener { binding?.editText?.setText((binding as ActivityMainBinding).editText.text.toString() + "4") } binding?.buttonFive?.setOnClickListener { binding?.editText?.setText((binding as ActivityMainBinding).editText.text.toString() + "5") } binding?.buttonSix?.setOnClickListener { binding?.editText?.setText((binding as ActivityMainBinding).editText.text.toString() + "6") } binding?.buttonSeven?.setOnClickListener { binding?.editText?.setText((binding as ActivityMainBinding).editText.text.toString() + "7") } binding?.buttonEight?.setOnClickListener { binding?.editText?.setText((binding as ActivityMainBinding).editText.text.toString() + "8") } binding?.buttonNine?.setOnClickListener { binding?.editText?.setText((binding as ActivityMainBinding).editText.text.toString() + "9") } binding!!.buttonAdd.setOnClickListener { computeCalculation() CURRENT_ACTION = ADDITION binding!!.infoTextView.setText(decimalFormat.format(valueOne) + "+") binding!!.editText.setText(null) } binding!!.buttonSubtract.setOnClickListener { computeCalculation() CURRENT_ACTION = SUBTRACTION binding!!.infoTextView.setText(decimalFormat.format(valueOne) + "-") binding!!.editText.setText(null) } binding!!.buttonMultiply.setOnClickListener { computeCalculation() CURRENT_ACTION = MULTIPLICATION binding!!.infoTextView.setText(decimalFormat.format(valueOne) + "*") binding!!.editText.setText(null) } binding!!.buttonDivide.setOnClickListener { computeCalculation() CURRENT_ACTION = DIVISION binding!!.infoTextView.setText(decimalFormat.format(valueOne) + "/") binding!!.editText.setText(null) } binding!!.buttonEqual.setOnClickListener { computeCalculation() binding!!.infoTextView.text = binding!!.infoTextView.text.toString() + decimalFormat.format(valueTwo) + " = " + decimalFormat.format(valueOne) valueOne = java.lang.Double.NaN CURRENT_ACTION = '0' } binding!!.buttonClear.setOnClickListener { if (binding!!.editText.text.length > 0) { val currentText = binding!!.editText.text binding!!.editText.setText(currentText.subSequence(0, currentText.length - 1)) } else { valueOne = java.lang.Double.NaN valueTwo = java.lang.Double.NaN binding!!.editText.setText("") binding!!.infoTextView.text = "" } } } 

Por favor, ayúdame a resolver el error.