0

I've got a series of float numbers; I want to display them as they are; but while I use String.getValueOf .0 will be added to my numbers ie 10 is shows as 10.0 what should i do to prevent this mess ?

Shervin4030
  • 27
  • 1
  • 9

3 Answers3

2

Try

if(stringVariable.endsWith(".0")) stringVariable = stringVariable.replace(".0" , "");

This way it will remove .0 only if the string ends with .0

Hope this helps.

anestv
  • 543
  • 6
  • 28
1

You can change from float to int using Math.round()

Arcantos
  • 1,052
  • 1
  • 13
  • 28
0

using something like sprintf would do it

String.format("%.0f", value);
0xFADE
  • 832
  • 5
  • 7