- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试学习java以进入android编程
对于我的练习,我正在尝试编写一个带有基本算术运算和小数点按钮的计算器程序
我尝试使用原始数字类型(例如 int 和 double)来执行此操作,但是如果我使用 double 作为变量类型,则诸如 2.111 之类的数字将显示为 2.11099999,但除此之外,它似乎工作正常( my question about this is given here )< br/>正如我的另一个问题的答案中所建议的,我修改了程序以使用 BigDecimal 数据类型而不是 double,但是现在当我单击 1 按钮时,尾数显示为 1.0,而不是像之前的程序中那样仅显示 1用过双
我怎样才能解决这个问题?
更新尾数的代码:
public void updateMantissa(){
// mantissa_valueBD = BigDecimal.valueOf(mantissa_value);
if(mantissa_value == BigDecimal.ZERO){
mantissa_str = "0";
}
/*
else if(ceil(mantissa_value) == mantissa_value){
mantissa_str = String.valueOf(mantissa_valueBD);
mantissa_str = mantissa_str.substring(0, mantissa_str.length() - 2 );
}
else{
mantissa_str = String.valueOf(mantissa_valueBD);
mantissa_str = mantissa_str.substring(0, Math.min(mantissa_str.length(), 10));
}
*/
// /*
else if(mantissa_value.setScale(0, RoundingMode.CEILING)== mantissa_value){
// mantissa_str = String.valueOf(mantissa_value);
mantissa_str = mantissa_value.toString();
mantissa_str = mantissa_str.substring(0, mantissa_str.length() - 4 );
}
else{
mantissa_str = String.valueOf(mantissa_value);
mantissa_str = mantissa_str.substring(0, Math.min(mantissa_str.length(), 10));
}
// */
TextView thisText = (TextView) findViewById(R.id.mantissa);
thisText.setText(mantissa_str);
}
完整代码(MainActivity 类):
package com.example.calculator;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
import static java.lang.Math.pow;
// import static java.lang.Math.ceil;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class MainActivity extends Activity {
// private double mantissa_value = 0;
// private BigDecimal mantissa_value = new BigDecimal(0);
// private BigDecimal opr1BD, opr2BD, resBD, mantissa_valueBD;
/*
private double opr1 = 0;
private double opr2 = 0;
private double res = 0;
// */
BigDecimal opr1 = BigDecimal.ZERO;
BigDecimal opr2 = BigDecimal.ZERO;
BigDecimal res = BigDecimal.ZERO;
BigDecimal tempBD = BigDecimal.ZERO;
BigDecimal mantissa_value = BigDecimal.ZERO;
private enum OprTypes {NONE, PLUS, MINUS, MULT, DIV}
OprTypes oprLatest = OprTypes.NONE;
private boolean oprPlusClicked = false;
private boolean oprMinusClicked = false;
private boolean oprMultClicked = false;
private boolean oprDivClicked = false;
private boolean decimalClicked = false;
private int numOfClicksAfterDecimal = 0;
private String mantissa_str;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
updateMantissa();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void updateMantissa(){
// mantissa_valueBD = BigDecimal.valueOf(mantissa_value);
if(mantissa_value == BigDecimal.ZERO){
mantissa_str = "0";
}
/*
else if(ceil(mantissa_value) == mantissa_value){
mantissa_str = String.valueOf(mantissa_valueBD);
mantissa_str = mantissa_str.substring(0, mantissa_str.length() - 2 );
}
else{
mantissa_str = String.valueOf(mantissa_valueBD);
mantissa_str = mantissa_str.substring(0, Math.min(mantissa_str.length(), 10));
}
*/
// /*
else if(mantissa_value.setScale(0, RoundingMode.CEILING)== mantissa_value){
// mantissa_str = String.valueOf(mantissa_value);
mantissa_str = mantissa_value.toString();
mantissa_str = mantissa_str.substring(0, mantissa_str.length() - 4 );
}
else{
mantissa_str = String.valueOf(mantissa_value);
mantissa_str = mantissa_str.substring(0, Math.min(mantissa_str.length(), 10));
}
// */
TextView thisText = (TextView) findViewById(R.id.mantissa);
thisText.setText(mantissa_str);
}
public void onClkBn0(View view){
TextView thisText = (TextView) findViewById(R.id.mantissa);
if(decimalClicked == false){
tempBD = mantissa_value.multiply(BigDecimal.valueOf(10.0));
mantissa_value = mantissa_value.add(BigDecimal.valueOf(0.0));
updateMantissa();
}
else{
if(mantissa_value == BigDecimal.ZERO){
if(numOfClicksAfterDecimal == 1){
mantissa_str = mantissa_str + ".0";
}
else{
mantissa_str = mantissa_str + "0";
}
}
else if(mantissa_value.setScale(0, RoundingMode.CEILING)== mantissa_value){
if(numOfClicksAfterDecimal == 1){
mantissa_str = mantissa_str + ".0";
}
else{
mantissa_str = mantissa_str + "0";
}
}
// mantissa_value = mantissa_value + pow(10, -numOfClicksAfterDecimal)*0;
tempBD = BigDecimal.valueOf(pow(10, -numOfClicksAfterDecimal)*0);
mantissa_value = mantissa_value.add(tempBD);
numOfClicksAfterDecimal++;
thisText.setText(mantissa_str);
}
}
public void onClkBn1(View view){
if(decimalClicked == false){
// mantissa_value = mantissa_value*10+1;
tempBD = mantissa_value.multiply(BigDecimal.valueOf(10.0));
mantissa_value = tempBD.add(BigDecimal.valueOf(1.0));
}
else{
// mantissa_value = mantissa_value + pow(10, -numOfClicksAfterDecimal)*1;
tempBD = BigDecimal.valueOf(pow(10, -numOfClicksAfterDecimal)*1);
mantissa_value = mantissa_value.add(tempBD);
numOfClicksAfterDecimal++;
}
updateMantissa();
}
public void onClkBn2(View view){
if(decimalClicked == false){
// mantissa_value = mantissa_value*10+2;
tempBD = mantissa_value.multiply(BigDecimal.valueOf(10.0));
mantissa_value = tempBD.add(BigDecimal.valueOf(2.0));
}
else{
// mantissa_value = mantissa_value + pow(10, -numOfClicksAfterDecimal)*2;
tempBD = BigDecimal.valueOf(pow(10, -numOfClicksAfterDecimal)*2);
mantissa_value = mantissa_value.add(tempBD);
numOfClicksAfterDecimal++;
}
updateMantissa();
}
public void onClkBn3(View view){
if(decimalClicked == false){
// mantissa_value = mantissa_value*10+3;
tempBD = mantissa_value.multiply(BigDecimal.valueOf(10.0));
mantissa_value = tempBD.add(BigDecimal.valueOf(3.0));
}
else{
// mantissa_value = mantissa_value + pow(10, -numOfClicksAfterDecimal)*3;
tempBD = BigDecimal.valueOf(pow(10, -numOfClicksAfterDecimal)*3);
mantissa_value = mantissa_value.add(tempBD);
numOfClicksAfterDecimal++;
}
updateMantissa();
}
public void onClkBn4(View view){
if(decimalClicked == false){
// mantissa_value = mantissa_value*10+4;
tempBD = mantissa_value.multiply(BigDecimal.valueOf(10.0));
mantissa_value = tempBD.add(BigDecimal.valueOf(4.0));
}
else{
// mantissa_value = mantissa_value + pow(10, -numOfClicksAfterDecimal)*4;
tempBD = BigDecimal.valueOf(pow(10, -numOfClicksAfterDecimal)*4);
mantissa_value = mantissa_value.add(tempBD);
numOfClicksAfterDecimal++;
}
updateMantissa();
}
public void onClkBn5(View view){
if(decimalClicked == false){
// mantissa_value = mantissa_value*10+5;
tempBD = mantissa_value.multiply(BigDecimal.valueOf(10.0));
mantissa_value = tempBD.add(BigDecimal.valueOf(5.0));
}
else{
// mantissa_value = mantissa_value + pow(10, -numOfClicksAfterDecimal)*5;
tempBD = BigDecimal.valueOf(pow(10, -numOfClicksAfterDecimal)*5);
mantissa_value = mantissa_value.add(tempBD);
numOfClicksAfterDecimal++;
}
updateMantissa();
}
public void onClkBn6(View view){
if(decimalClicked == false){
// mantissa_value = mantissa_value*10+6;
tempBD = mantissa_value.multiply(BigDecimal.valueOf(10.0));
mantissa_value = tempBD.add(BigDecimal.valueOf(6.0));
}
else{
// mantissa_value = mantissa_value + pow(10, -numOfClicksAfterDecimal)*6;
tempBD = BigDecimal.valueOf(pow(10, -numOfClicksAfterDecimal)*6);
mantissa_value = mantissa_value.add(tempBD);
numOfClicksAfterDecimal++;
}
updateMantissa();
}
public void onClkBn7(View view){
if(decimalClicked == false){
// mantissa_value = mantissa_value*10+7;
tempBD = mantissa_value.multiply(BigDecimal.valueOf(10.0));
mantissa_value = tempBD.add(BigDecimal.valueOf(7.0));
}
else{
// mantissa_value = mantissa_value + pow(10, -numOfClicksAfterDecimal)*7;
tempBD = BigDecimal.valueOf(pow(10, -numOfClicksAfterDecimal)*7);
mantissa_value = mantissa_value.add(tempBD);
numOfClicksAfterDecimal++;
}
updateMantissa();
}
public void onClkBn8(View view){
if(decimalClicked == false){
// mantissa_value = mantissa_value*10+8;
tempBD = mantissa_value.multiply(BigDecimal.valueOf(10.0));
mantissa_value = tempBD.add(BigDecimal.valueOf(8.0));
}
else{
// mantissa_value = mantissa_value + pow(10, -numOfClicksAfterDecimal)*8;
tempBD = BigDecimal.valueOf(pow(10, -numOfClicksAfterDecimal)*8);
mantissa_value = mantissa_value.add(tempBD);
numOfClicksAfterDecimal++;
}
updateMantissa();
}
public void onClkBn9(View view){
if(decimalClicked == false){
// mantissa_value = mantissa_value*10+9;
tempBD = mantissa_value.multiply(BigDecimal.valueOf(10.0));
mantissa_value = tempBD.add(BigDecimal.valueOf(9.0));
}
else{
// mantissa_value = mantissa_value + pow(10, -numOfClicksAfterDecimal)*9;
tempBD = BigDecimal.valueOf(pow(10, -numOfClicksAfterDecimal)*9);
mantissa_value = mantissa_value.add(tempBD);
numOfClicksAfterDecimal++;
}
updateMantissa();
}
public void onClkBnDot(View view){
decimalClicked = true;
}
public void onClkBnCan(View view){
mantissa_value = BigDecimal.ZERO;
opr1 = BigDecimal.ZERO;
opr2 = BigDecimal.ZERO;
res = BigDecimal.ZERO;
/*
opr1 = 0;
opr2 = 0;
res = 0;
// */
oprLatest = OprTypes.NONE;
oprPlusClicked = false;
oprMinusClicked = false;
oprMultClicked = false;
oprDivClicked = false;
decimalClicked = false;
numOfClicksAfterDecimal = 1;
}
public void onClkBnPlus(View view){
if(oprPlusClicked == false){
oprPlusClicked = true;
opr1 = mantissa_value;
// mantissa_value = 0;
mantissa_value = BigDecimal.ZERO;
}
else{
// this should mean opr1 already has some value in it
// so add the current mantissa value to opr1
// opr1 = opr1 + mantissa_value;
opr1 = opr1.add(mantissa_value);
mantissa_value = BigDecimal.ZERO;
}
oprLatest = OprTypes.PLUS;
}
public void onClkBnMinus(View view){
if(oprMinusClicked == false){
oprMinusClicked = true;
opr1 = mantissa_value;
mantissa_value = BigDecimal.ZERO;
}
else{
// this should mean opr1 already has some value in it
// so add the current mantissa value to opr1
// opr1 = opr1 - mantissa_value;
opr1 = opr1.subtract(mantissa_value);
mantissa_value = BigDecimal.ZERO;
}
oprLatest = OprTypes.MINUS;
}
public void onClkBnMult(View view){
if(oprMultClicked == false){
oprMultClicked = true;
opr1 = mantissa_value;
mantissa_value = BigDecimal.ZERO;
}
else{
// this should mean opr1 already has some value in it
// so add the current mantissa value to opr1
// opr1 = opr1 * mantissa_value;
opr1 = opr1.multiply(mantissa_value);
mantissa_value = BigDecimal.ZERO;
}
oprLatest = OprTypes.MULT;
}
public void onClkBnDiv(View view){
if(oprDivClicked == false){
oprDivClicked = true;
opr1 = mantissa_value;
mantissa_value = BigDecimal.ZERO;
}
else{
// this should mean opr1 already has some value in it
// so add the current mantissa value to opr1
// opr1 = opr1 / mantissa_value;
opr1 = opr1.divide(mantissa_value);
mantissa_value = BigDecimal.ZERO;
}
oprLatest = OprTypes.DIV;
}
public void onClkBnRes(View view){
if(oprPlusClicked == true || oprMinusClicked == true || oprMultClicked == true || oprDivClicked == true){
switch(oprLatest){
case PLUS:
// mantissa_value = opr1 + mantissa_value;
mantissa_value = opr1.add(mantissa_value);
break;
case MINUS:
// mantissa_value = opr1 - mantissa_value;
mantissa_value = opr1.subtract(mantissa_value);
break;
case MULT:
// mantissa_value = opr1 * mantissa_value;
mantissa_value = opr1.multiply(mantissa_value);
break;
case DIV:
// mantissa_value = opr1 / mantissa_value;
mantissa_value = opr1.divide(mantissa_value);
break;
case NONE:
break;
}
}
oprLatest = OprTypes.NONE;
oprPlusClicked = false;
oprMinusClicked = false;
oprMultClicked = false;
oprDivClicked = false;
updateMantissa();
}
}
------编辑------
如果我做这样的事情,
public static void main(String[] args){
// double a;
a = 2.111;
System.out.println(a);
}
它准确地显示 2.111,而不是 2.1109999。这是为什么?
------ 编辑 2 ------
我对程序的逻辑进行了更改,以便它现在可以在字符串上执行与显示相关的任何操作,同时使用 Double.parseDouble() 函数将尾数字符串值转换为 double 以执行与显示相关的任何操作计算。如果有人想评论的话,更新后的代码如下所示
package com.example.calculator;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
import static java.lang.Math.pow;
import static java.lang.Math.ceil;
// import java.math.BigDecimal;
import java.text.NumberFormat;
public class MainActivity extends Activity {
private double mantissa_value = 0;
// private BigDecimal mantissa_value = new BigDecimal(0);
// private BigDecimal opr1BD, opr2BD, resBD, mantissa_valueBD;
// /*
private double opr1 = 0;
// */
NumberFormat number = NumberFormat.getNumberInstance();
private enum OprTypes {NONE, PLUS, MINUS, MULT, DIV}
OprTypes oprLatest = OprTypes.NONE;
private boolean oprPlusClicked = false;
private boolean oprMinusClicked = false;
private boolean oprMultClicked = false;
private boolean oprDivClicked = false;
private boolean decimalClicked = false;
private boolean resetMantissa = true;
private String mantissa_str;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// updateMantissa();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void updateMantissa(){
// This is the version that should get called from the num pad buttons, 0 - 9
updateMantissa(true);
}
public void updateMantissa(boolean frmNumPad){
// this is the version that should get called from other buttons besides the num pad buttons
if(frmNumPad != true){
long mantissa_val_int_part = (long)mantissa_value;
if(mantissa_value == (double)mantissa_val_int_part){
mantissa_str = mantissa_str.substring(0, mantissa_str.length() - 2 );
}
else if (mantissa_str.length() > 10){
mantissa_str = mantissa_str.substring(0, Math.min(mantissa_str.length(), 10));
}
}
TextView thisText = (TextView) findViewById(R.id.mantissa);
thisText.setText(mantissa_str);
}
public void onClkBn0(View view){
if (resetMantissa == true){
mantissa_str = "";
resetMantissa = false;
}
if(decimalClicked == false){
if( !(Double.parseDouble(mantissa_str)==0.0) )
mantissa_str = mantissa_str + "0";
}
else{
mantissa_str = mantissa_str + "0";
}
TextView thisText = (TextView) findViewById(R.id.mantissa);
thisText.setText(mantissa_str);
}
public void onClkBn1(View view){
if (resetMantissa == true){
mantissa_str = "";
resetMantissa = false;
}
mantissa_str = mantissa_str + "1";
mantissa_value = Double.parseDouble(mantissa_str);
updateMantissa();
}
public void onClkBn2(View view){
if (resetMantissa == true){
mantissa_str = "";
resetMantissa = false;
}
mantissa_str = mantissa_str + "2";
mantissa_value = Double.parseDouble(mantissa_str);
updateMantissa();
}
public void onClkBn3(View view){
if (resetMantissa == true){
mantissa_str = "";
resetMantissa = false;
}
mantissa_str = mantissa_str + "3";
mantissa_value = Double.parseDouble(mantissa_str);
updateMantissa();
}
public void onClkBn4(View view){
if (resetMantissa == true){
mantissa_str = "";
resetMantissa = false;
}
mantissa_str = mantissa_str + "4";
mantissa_value = Double.parseDouble(mantissa_str);
updateMantissa();
}
public void onClkBn5(View view){
if (resetMantissa == true){
mantissa_str = "";
resetMantissa = false;
}
mantissa_str = mantissa_str + "5";
mantissa_value = Double.parseDouble(mantissa_str);
updateMantissa();
}
public void onClkBn6(View view){
if (resetMantissa == true){
mantissa_str = "";
resetMantissa = false;
}
mantissa_str = mantissa_str + "6";
mantissa_value = Double.parseDouble(mantissa_str);
updateMantissa();
}
public void onClkBn7(View view){
if (resetMantissa == true){
mantissa_str = "";
resetMantissa = false;
}
mantissa_str = mantissa_str + "7";
mantissa_value = Double.parseDouble(mantissa_str);
updateMantissa();
}
public void onClkBn8(View view){
if (resetMantissa == true){
mantissa_str = "";
resetMantissa = false;
}
mantissa_str = mantissa_str + "8";
mantissa_value = Double.parseDouble(mantissa_str);
updateMantissa();
}
public void onClkBn9(View view){
if (resetMantissa == true){
mantissa_str = "";
resetMantissa = false;
}
mantissa_str = mantissa_str + "9";
mantissa_value = Double.parseDouble(mantissa_str);
updateMantissa();
}
public void onClkBnDot(View view){
if(decimalClicked == false){
decimalClicked = true;
mantissa_str = mantissa_str + ".";
}
}
public void onClkBnCan(View view){
mantissa_value = 0;
// /*
opr1 = 0;
// */
oprLatest = OprTypes.NONE;
oprPlusClicked = false;
oprMinusClicked = false;
oprMultClicked = false;
oprDivClicked = false;
decimalClicked = false;
mantissa_value = 0;
opr1 = 0;
resetMantissa = true;
updateMantissa(false);
}
public void onClkBnPlus(View view){
if(oprPlusClicked == false){
oprPlusClicked = true;
decimalClicked = false;
opr1 = Double.parseDouble(mantissa_str);
mantissa_value = 0;
}
else{
// this should mean opr1 already has some value in it
// so add the current mantissa value to opr1
mantissa_value = Double.parseDouble(mantissa_str);
opr1 = opr1 + mantissa_value;
mantissa_value = opr1;
decimalClicked = false;
mantissa_str = Double.toString(mantissa_value);
updateMantissa(false);
}
oprLatest = OprTypes.PLUS;
resetMantissa = true;
}
public void onClkBnMinus(View view){
if(oprMinusClicked == false){
oprMinusClicked = true;
decimalClicked = false;
opr1 = Double.parseDouble(mantissa_str);
mantissa_value = 0;
}
else{
// this should mean opr1 already has some value in it
// so add the current mantissa value to opr1
mantissa_value = Double.parseDouble(mantissa_str);
opr1 = opr1 - mantissa_value;
mantissa_value = opr1;
decimalClicked = false;
mantissa_str = Double.toString(mantissa_value);
updateMantissa(false);
}
oprLatest = OprTypes.MINUS;
resetMantissa = true;
}
public void onClkBnMult(View view){
if(oprMultClicked == false){
oprMultClicked = true;
decimalClicked = false;
opr1 = Double.parseDouble(mantissa_str);
mantissa_value = 0;
}
else{
// this should mean opr1 already has some value in it
// so add the current mantissa value to opr1
mantissa_value = Double.parseDouble(mantissa_str);
opr1 = opr1 * mantissa_value;
mantissa_value = opr1;
decimalClicked = false;
mantissa_str = Double.toString(mantissa_value);
updateMantissa(false);
}
oprLatest = OprTypes.MULT;
resetMantissa = true;
}
public void onClkBnDiv(View view){
if(oprDivClicked == false){
oprDivClicked = true;
decimalClicked = false;
opr1 = Double.parseDouble(mantissa_str);
mantissa_value = 0;
}
else{
// this should mean opr1 already has some value in it
// so add the current mantissa value to opr1
mantissa_value = Double.parseDouble(mantissa_str);
opr1 = opr1 / mantissa_value;
mantissa_value = opr1;
decimalClicked = false;
mantissa_str = Double.toString(mantissa_value);
updateMantissa(false);
}
oprLatest = OprTypes.DIV;
resetMantissa = true;
}
public void onClkBnRes(View view){
mantissa_value = Double.parseDouble(mantissa_str);
if(oprPlusClicked == true || oprMinusClicked == true || oprMultClicked == true || oprDivClicked == true){
switch(oprLatest){
case PLUS:
mantissa_value = opr1 + mantissa_value;
break;
case MINUS:
mantissa_value = opr1 - mantissa_value;
break;
case MULT:
mantissa_value = opr1 * mantissa_value;
break;
case DIV:
mantissa_value = opr1 / mantissa_value;
break;
case NONE:
break;
}
}
oprLatest = OprTypes.NONE;
oprPlusClicked = false;
oprMinusClicked = false;
oprMultClicked = false;
oprDivClicked = false;
decimalClicked = false;
mantissa_str = Double.toString(mantissa_value);
updateMantissa(false);
}
public void onClkBnOff(View view){
finish();
}
}
最佳答案
通过阅读您链接到的问题,尚不清楚您关心的是 float 精度问题还是 float 打印问题。最初问题中的人们建议支持 BigDecimal,但我感觉您最初的担忧与后者有关 - 即打印值 - 这就是您仍然面临的问题。
使用String.valueOf()
打印 double 值几乎从来都不是一个好主意。幕后发生的事情是根据默认区域设置将浮点值转换为字符串。您应该自己执行转换,而不是让系统进行转换。
实现此目的的方法是使用 DecimalFormat
类。示例代码:
double mantissa_value = 2.11099999;
DecimalFormat df = new DecimalFormat("0.###");
// Un-comment the line below to take English locale into account when converting
//df.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.ENGLISH));
// will print '2.11099999' this is what you get in your original case
System.out.println( String.valueOf(mantissa_value) );
// will print '2.111' or '2,111' depending on your locale. if you uncomment the line above for English locale it will print '2.111'
System.out.println( df.format(mantissa_value) );
上述十进制格式将打印小数点后 1、2 或 3 位数字的 double 值。如果您需要可变精度,您可以在用户输入字符时在变量中保留一个计数器,然后使用该计数器生成具有所需十进制数字的 DecimalFormat
。对于 BigDecimal 情况可以采用相同的方法。我希望这有帮助
关于java - 如何将 BigDecimal 正确显示为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17651131/
我是一名优秀的程序员,十分优秀!