显示没有科学记数法的双变量的值

时间:2017-05-05 10:19:59

标签: android double scientific-notation

我有两个数据类型为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);


    }
}

1 个答案:

答案 0 :(得分:0)

Log.d("tag", "" + new BigDecimal(catchBookingQtyDoubleForm * catchRatePerBrickDoubleForm));
相关问题