0

I'm developing an android application recently and I found out that the display of the output are quite weird especially when it comes to number.

For example, after going through a formulation.

The value shown on the TextView is 1.5460385687E-11

My question is, how can I display the current above output in a proper way such as 1.546E-11 or 1.546x10^11 ?

As requested, my code for displaying to the output.

double result = tPower * tGain * rGain * Math.pow(lamda / (4 * Math.PI *distance),2)/ light / 100;
((TextView)findViewById(R.id.textFreeSpacePrw)).setText(Double.toString(result));
Beta Tracks
  • 263
  • 2
  • 5
  • 14

1 Answers1

0

You could use a DecimalFormat to format the result of your calculation before adding it to the TextView. The DecimalFormat class is configured using a pattern given in the constructor, such as "0.###E+0"

See http://developer.android.com/reference/java/text/DecimalFormat.html