Home » Java BigDecimal movePointLeft() method with Examples

Java BigDecimal movePointLeft() method with Examples

by Online Tutorials Library

Java BigDecimal movePointLeft() method

The movePointLeft() method of Java BigDecimal class is used to move the decimal point of the current BigDecimal by n places to the left.

  • Note:
  • 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).

Syntax:

Parameter:

n: number of places to move the decimal point to the left.

Exception:

ArithmeticException– If scale overflows, then it throws exception:

Returns:

It returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the left.

Example 1

Test it Now

Output:

Final result after 3 move point left =0.12323  

Example 2

Test it Now

Output:

Final result after 4 move point left =5345440.0000  

Example 3

Test it Now

Output:

Final result after -2 move point left =53454400  

Example 4

Test it Now

Output:

Final result after -2 move point left =-553742733.457  

Next TopicJava BigDecimal

You may also like