0
我想将使用DecimalFormat的浮点格式设置为给定的精度。我有什么是这个DecimalFormat精度无法正常工作
val formatter = DecimalFormat(if (precision > 0) "#0.${"0".repeat(precision)}" else "#")
比方说,精度为2,当我做
formatter.format(20.0f).toFloat()
我得到的输出作为20.0f
,而不是3210
由于它的工作... – Sagar