显示没有科学记数法的双精度变量的值
Displaying value of a double variable without Scientific Notation
我有两个数据类型为 double 的变量,当我将这些变量相乘时,它们 return 结果为科学形式,但我的要求是以正常的人类可读形式显示结果。
例如:
当我将 9854795 和 8.9 相乘时,它 return 的结果是 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);
}
}
Log.d("tag", "" + new BigDecimal(catchBookingQtyDoubleForm * catchRatePerBrickDoubleForm));
我有两个数据类型为 double 的变量,当我将这些变量相乘时,它们 return 结果为科学形式,但我的要求是以正常的人类可读形式显示结果。 例如: 当我将 9854795 和 8.9 相乘时,它 return 的结果是 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);
}
}
Log.d("tag", "" + new BigDecimal(catchBookingQtyDoubleForm * catchRatePerBrickDoubleForm));