如果插入EditText中的数字以点+任何数字结尾,则需要有条件的。例子:
129.2
如果以此结尾,则需要这样的新值。
192.20
提前致谢。
为什么不使用aNumberFormat
作为输出?
double a = 123.2;
NumberFormat formatter = new DecimalFormat("#0.00");
String aFormat = formatter.format(a);
System.out.println(aFormat); // --> 123.20
因此,您可以轻松更改您喜欢的输出格式。更多信息:NumberFormat-Android
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句