Description Of BigDecimal: movePointLeft(int n)
The java.math.BigDecimal.movePointLeft(int n) returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the left. If n is non-negative, the call merely adds n to the scale. If n is negative, the call is equivalent to movePointRight(-n) . The BigDecimal returned by this call has value (this ? 10-n ) and scale max(this.scale()+n, 0) .BigDecimal.movePointLeft(int n) method returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the left.
Code Example Java BigDecimal
import java.math.BigDecimal;
public class BigDecimalExam {
 public static void main(String[] args) {
  BigDecimal bg1 = new BigDecimal("-75");
  BigDecimal bg2 = new BigDecimal("25");
  BigDecimal bg3 = bg1.movePointLeft(3); // 3 points left
  BigDecimal bg4 = bg2.movePointLeft(-2);// 2 points right
  // print bg3, bg4 values
  System.out.println(bg3);
  System.out.println(bg4);
 }
}
ไม่มีความคิดเห็น :
แสดงความคิดเห็น