0

When I run this code:

  Double test = (23.1d + 0.1d);
  Log.i(Constants.TAG, "Test: " + test);

I get:

 Test: 23.200000000000003

I need to add values that will at most have two decimals. For example 19.99 + 0.1 =20.09, how can I do it so that precision is not lost?

user2983041
  • 1,761
  • 4
  • 19
  • 31
  • 1
    https://stackoverflow.com/questions/2808535/round-a-double-to-2-decimal-places I believe this will be helpful foryou. – Bethan Feb 08 '18 at 09:18

1 Answers1

0

double i2=i/60000;

tv.setText(new DecimalFormat("##.##").format(i2));

use this code