First, BigDecimal related methods
1.bigdecimal.setscale (int newscale, roundingmode roundingmode) format decimal point
Setscale (1) indicates that a decimal number is reserved and is rounded by default
Setscale (1,bigdecimal.round_down) directly removes the extra decimal digits, such as 2.35 will become 2.3
Setscale (1,BIGDECIMAL.ROUND_UP) Carry processing, 2.35 becomes 2.4
Setscale (1,bigdecimal.round_half_up) rounded, 2.35 turned 2.4
Setscale (1,bigdecimal.round_half_down) rounded, 2.35 becomes 2.3, if 5 is down
notes:(1). Parameter newscale: Refers to the number of decimal places you want to keep (2). The parameter roundingmode is a reserved mode for decimals. They are all constant fields in BigDecimal, and there are many kinds.For example: Bigdecimal.round_half_up means 4 to 5 in.
2.bigdecimal.scale (): Returns the number of digits after the decimal point.
Cases: BigDecimal b = new BigDecimal ("123.456"); B.scale ();--------------return 33.bigdecimal.divide (BigDecimal divisor, int scale, int roundingmode): divided by
(1) The result of dividing the BigDecimal object by divisor;(2) This result retains a scale decimal place, (3) Roundingmode is a retention mode, such as rounding, etc.;
4.add, subtract, multiply: add, subtract, multiply:
BigDecimal B1 = new BigDecimal ("9.655");
BigDecimal b2 = new BigDecimal ("5");
B1.add (B2); --------B1+b2 14.655
B1.subtract (B2); ----B1-B2 4.655
B1.multiply (B2); ----B1*B2 48.275
Java processing data-related methods