mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
NumberUtil.roundStr() 修改为使用toPlainString
This commit is contained in:
parent
a899435272
commit
92e1434187
@ -793,7 +793,7 @@ public class NumberUtil {
|
|||||||
* @return 新值
|
* @return 新值
|
||||||
*/
|
*/
|
||||||
public static String roundStr(double v, int scale) {
|
public static String roundStr(double v, int scale) {
|
||||||
return round(v, scale).toString();
|
return round(v, scale).toPlainString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -834,7 +834,7 @@ public class NumberUtil {
|
|||||||
* @since 3.2.2
|
* @since 3.2.2
|
||||||
*/
|
*/
|
||||||
public static String roundStr(String numberStr, int scale) {
|
public static String roundStr(String numberStr, int scale) {
|
||||||
return round(numberStr, scale).toString();
|
return round(numberStr, scale).toPlainString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -861,7 +861,7 @@ public class NumberUtil {
|
|||||||
* @since 3.2.2
|
* @since 3.2.2
|
||||||
*/
|
*/
|
||||||
public static String roundStr(double v, int scale, RoundingMode roundingMode) {
|
public static String roundStr(double v, int scale, RoundingMode roundingMode) {
|
||||||
return round(v, scale, roundingMode).toString();
|
return round(v, scale, roundingMode).toPlainString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -915,7 +915,7 @@ public class NumberUtil {
|
|||||||
* @since 3.2.2
|
* @since 3.2.2
|
||||||
*/
|
*/
|
||||||
public static String roundStr(String numberStr, int scale, RoundingMode roundingMode) {
|
public static String roundStr(String numberStr, int scale, RoundingMode roundingMode) {
|
||||||
return round(numberStr, scale, roundingMode).toString();
|
return round(numberStr, scale, roundingMode).toPlainString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,6 +137,9 @@ public class NumberUtilTest {
|
|||||||
public void roundStrTest() {
|
public void roundStrTest() {
|
||||||
final String roundStr = NumberUtil.roundStr(2.647, 2);
|
final String roundStr = NumberUtil.roundStr(2.647, 2);
|
||||||
Assert.assertEquals(roundStr, "2.65");
|
Assert.assertEquals(roundStr, "2.65");
|
||||||
|
|
||||||
|
final String roundStr1 = NumberUtil.roundStr(0, 10);
|
||||||
|
Assert.assertEquals(roundStr1, "0.0000000000");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user