I perform calculations using a double as follows:
int minutes;
double seconds;
double DecMinutes;
// Handle Dd in; DMS, and DMm out
Calculate myCalculate = new Calculate(inDecimal); {
double outMinutes = myCalculate.getMinute();
double outSeconds = myCalculate.getSecond();
double outDecMinute = myCalculate.getDecMinute();
minutes = (int) outMinutes;
seconds = outSeconds;
DecMinutes = outDecMinute;
} // end myCalculate
// Convert result back to String
c = Integer.toString(minutes);
((EditText)findViewById(R.id.txtDMSLatMin)).setText(c);
((EditText)findViewById(R.id.txtDMmLatMin)).setText(c);
c = Double.toString(seconds);
((EditText)findViewById(R.id.txtDMSLatSec)).setText(c);
c = Double.toString(DecMinutes);
((EditText)findViewById(R.id.txtDMmLatDecMin)).setText(c);
My main concern is with the double DecMinutes output. Because it’s a Decimal-Minutes calculation I need to use double. My layout already displays the decimal point as a fixed character so instead of displaying 0.0734 I want to display 0734 in the EditText box txtDMmLatDecMin.
Thanks!!
So basically, you want to drop the zero and the decimal point?
Maybe there is an easier way, but at the top of my head I am thinking you can use
String.split(). With the downside that you have to create a new String array to hold the values.So after you do this:
Then you can do:
Again, maybe there is an easier way. 🙂