将Float格式化为n个小数位
我需要将float格式化为“n”个小数位。
正在尝试BigDecimal,但返回值不正确...
public static float Redondear(float pNumero, int pCantidadDecimales) { // the function is call with the values Redondear(625.3f, 2) BigDecimal value = new BigDecimal(pNumero); value = value.setScale(pCantidadDecimales, RoundingMode.HALF_EVEN); // here the value is correct (625.30) return value.floatValue(); // but here the values is 625.3}
我需要返回一个浮点值,其中包含我指定的小数位数。
我不需要Float
价值回报Double
。
哆啦的时光机
蛊毒传说
LEATH