BigDecimal setScale and round
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: What is the difference between this two call? (Is there any?) // 1. new BigDecimal ( "3.53456" ). round ( new MathContext ( 4 , RoundingMode . HALF_UP )); // 2. new BigDecimal ( "3.53456" ). setScale ( 4 , RoundingMode . HALF_UP ); 回答1: One important point that is alluded to but not directly addressed is the difference between "precision" and "scale" and how they are used in the two statements. "precision" is the total number of significant digits in a number. "scale" is the number of digits to the right of the decimal point. The