Skip to content

Commit b74d093

Browse files
authored
Merge pull request #2741 from codomposer/fix/issue-2680
fix Big number issue in the guide
2 parents 4cd295d + 66977c8 commit b74d093

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/java/basis/bigdecimal.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public class BigDecimalUtil {
283283
* @return 返回转换结果
284284
*/
285285
public static float convertToFloat(double v) {
286-
BigDecimal b = new BigDecimal(v);
286+
BigDecimal b = BigDecimal.valueOf(v);
287287
return b.floatValue();
288288
}
289289

@@ -294,7 +294,7 @@ public class BigDecimalUtil {
294294
* @return 返回转换结果
295295
*/
296296
public static int convertsToInt(double v) {
297-
BigDecimal b = new BigDecimal(v);
297+
BigDecimal b = BigDecimal.valueOf(v);
298298
return b.intValue();
299299
}
300300

@@ -305,7 +305,7 @@ public class BigDecimalUtil {
305305
* @return 返回转换结果
306306
*/
307307
public static long convertsToLong(double v) {
308-
BigDecimal b = new BigDecimal(v);
308+
BigDecimal b = BigDecimal.valueOf(v);
309309
return b.longValue();
310310
}
311311

@@ -317,8 +317,8 @@ public class BigDecimalUtil {
317317
* @return 返回两个数中大的一个值
318318
*/
319319
public static double returnMax(double v1, double v2) {
320-
BigDecimal b1 = new BigDecimal(v1);
321-
BigDecimal b2 = new BigDecimal(v2);
320+
BigDecimal b1 = BigDecimal.valueOf(v1);
321+
BigDecimal b2 = BigDecimal.valueOf(v2);
322322
return b1.max(b2).doubleValue();
323323
}
324324

@@ -330,8 +330,8 @@ public class BigDecimalUtil {
330330
* @return 返回两个数中小的一个值
331331
*/
332332
public static double returnMin(double v1, double v2) {
333-
BigDecimal b1 = new BigDecimal(v1);
334-
BigDecimal b2 = new BigDecimal(v2);
333+
BigDecimal b1 = BigDecimal.valueOf(v1);
334+
BigDecimal b2 = BigDecimal.valueOf(v2);
335335
return b1.min(b2).doubleValue();
336336
}
337337

0 commit comments

Comments
 (0)