2017-05-05 48 views
1

我有兩個數據類型爲double的變量,當我乘以這些變量時,它們以科學形式返回結果,但我的要求是以正常的人類可讀形式顯示結果。 例如: 當我乘9854795和8.9返回的結果爲8.77076755E7代替87707675.5在沒有科學表示法的情況下顯示雙變量的值

這裏是我的計算值的函數:

private void calculatingTotalPaymentAmount() { 

    if (editTextBookingQuantity.getText().toString().equals("")) 
    { 
     editTextBookingQuantity.setError("Enter Booking Quantity to calculate Total Payment Amount"); 
     return; 
    } else if (editTextRatePerBrick.getText().toString().equals("")) 
    { 
     editTextRatePerBrick.setError("Enter Rate Per Brick to calculate Total Payment Amount"); 
     return; 
    } else { 

     //MathContext mc = new MathContext(4); // 4 precision 
     final double catchBookingQtyDoubleForm = Double.parseDouble(editTextBookingQuantity.getText().toString()); 
     final double catchRatePerBrickDoubleForm = Double.parseDouble(editTextRatePerBrick.getText().toString().trim()); 
     final double totalPaymentAmount = (catchBookingQtyDoubleForm * catchRatePerBrickDoubleForm); 
     //bg3 = bg1.multiply(bg2, mc); 
     //BigDecimal newValue = totalPaymentAmount.setScale(0, RoundingMode.DOWN); 
     editTextTotalPaymentAmount.setText(""+totalPaymentAmount); 


    } 
} 
+0

雙totalPaymentAmount將其更改爲BigDecimal和檢查 – Lingeshwaran

回答

0
Log.d("tag", "" + new BigDecimal(catchBookingQtyDoubleForm * catchRatePerBrickDoubleForm)); 
相關問題