0

i want to make a check in my app. If the double entered by the user has more decimals throw a popup to the user. Here is my code i tried many combinations but no one works

String bigStart = etVehicleMileageAtStartTour.getText().toString(),
      bigEnd = etVehicleMileageAtEndTour.getText().toString();
 if ((bigStart.indexOf(".") >= 0 && bigStart.indexOf(".") > bigStart.length() - 2)
 || (bigEnd.indexOf(".") >= 0 && bigEnd.indexOf(".") > bigEnd.length() - 2)) 

{
 // throw popup
}

I tried also to convert to big decimal and use scale method but it is not working

BigDecimal bigAtStart = BigDecimal.valueOf(vehiculeMileageAtStart);
BigDecimal bigAtEnd = BigDecimal.valueOf(vehiculeMileageAtEnd);
int i = bigAtEnd.scale();
int j = bigAtStart.scale();
if (bigAtEnd.scale() > 99 || bigAtStart.scale() > 99) {
}

Thanks in advance.

Dr Mido
  • 2,414
  • 4
  • 32
  • 72
Houssein Zouari
  • 712
  • 6
  • 18

0 Answers0