android TextView自动显示成科学计算法

时间:2023-01-09 08:57:51

就例如:

        TextView textView1 = (TextView) findViewById(R.id.TextView1);
        double test = 99999999999.99;
        textView1.setText(String.valueOf(test));

会显示成9.999999999E10

解决办法

修改成:

        double test = 99999999999.99;
        TextView textView2 = (TextView) findViewById(R.id.TextView2);
        textView2.setText(String.format(Locale.ENGLISH, "%.3f", test));

会显示99999999999.990