0

I am trying to get rid of the .0 left behind a float number when I add whole numbers together. ex. if i do 10+10 it will print out 20.0 but i want it to print out 20 unless there is a decimal in the number. P.S ive been looking all over on this site and cant find the anser to my question so why did someone make this a duplicate makes no sense.

float numOne = Float.parseFloat(numberOne.getText());
    float numTwo = Float.parseFloat(numberTwo.getText());
    float anser = numOne+numTwo;
    String AR = String.valueOf(anser);
        anserLabel.setText(AR);
Daniel
  • 15
  • 4
  • 1
    Cast value to an int? – Tyler Nichols Nov 07 '16 at 15:30
  • why would I cast it to an int...... I need it to be float cause there will be decimals in the numbers, its just that if the 2 numbers put together are whole dumbers i dont want the useless .0 after the whole number – Daniel Nov 08 '16 at 17:36

0 Answers0