import java.math.BigDecimal; class ProcessPositionTest {/ ** * * @param val bits processed are processed to distinguish the number of processing * @param processKind * @param positionKind distinguishing bits * @return BigDecimal * / private static BigDecimal processPosition (BigDecimal val String processkind, int positionkind) {
Val = val.divide (New BigDecimal (Math.Pow (10, PositionKind)), BigDecimal.Round_Half_Even;
IF ("0" .Equals (processkind)) {val = val.setscale (0, BigDecimal.Round_down);} else if ("1" .Equals (processkind)) {val = val.setscale (0, BigDecimal.Round_up } Else if ("2" .Equals (processkind)) {val = val.setscale (0, BigDecimal.Round_Half_Even);} Val = val.multiply (New BigDecimal));
Return Val;
Public static void main (string [] args) {BigDecimal D1 = New BigDecimal (21.12354);
System.out.println ((RNDPUCTEST.PROCESSPSITION (D1, "2", -3)). DoubleValue ());}}