0

My double value is something like 0.000659 and it show up like 6.6e-05.

I have looked all over but because I don't know what it is doing, I don't know what to look for.

Does anyone know what it is doing or how to fix it? My code:

Double value= jsonObject.get("last").asDouble();
Toast.makeText(getBaseContext(), "value"+value, Toast.LENGTH_LONG).show();
SPatrickApps
  • 538
  • 8
  • 21

2 Answers2

2

You can try something like this:

    System.out.println(String.format("%.6f", value));

Note that 6 indicate how many decimal places you want to display.

Baby
  • 5,062
  • 3
  • 30
  • 52
1
Double value = jsonObject.get("last").asDouble();
Formatter formatter = new Formatter(Locale.US);
String res = formatter.format("%+0.6f", value);

res will be something like "0.000659"

AgilePro
  • 5,588
  • 4
  • 33
  • 56