package Test; import java.math.BigDecimal; //Introduce this package public class Test { double i = 3.856; // Round off decimals // Rounding up // Rounding to two decimal places // Round up, take the upper limit // Round off decimals // Rounding to two decimal places // Round up, take the upper limit |
// print the result
Round off decimals: Math.floor(3.856)=3
Round off: (3.856)=4
Round off: (3.856)=3.86 Round off
: Math.ceil(3.856) =4 Round off
decimals: Math .floor(-3.856)=-4
rounding: (-3.856)=-4 rounding: (-3.856)
=-3.86
rounding (-3.856)=-3 maolinquan