0
我想將String.ValueOf舍入到最近的整數。任何想法如何獲得String.valueOf(結果)到最近的整數。Round String.ValueOf到最近的整數
public void onClick(View v) {
double result =0;
double result1 =0;
double a = Double.parseDouble(weightEntered.getText().toString().trim());
double b = 2.2;
if(v == button_convert)
{
if(lbs_kg.isChecked() == true) {
result = (a/b);
String str = String.valueOf(result);
t1.setText(str);
}
Math.round(將String.valueOf(結果))應該做的:) –
@SandeepBhandari想想看,一秒鐘。 –
在這裏看到的解決方案:http://stackoverflow.com/questions/2808535/round-a-double-to-2-decimal-places – Pooya