Home » Java BigDecimal movePointRight() method with Examples

Java BigDecimal movePointRight() method with Examples

by Online Tutorials Library

Java BigDecimal movePointRight() method

The movePointRight() method of java BigDecimal class is used to move the decimal point of the current BigDecimal by n places to the right.

  • Note:
  • If n is non-negative, the call merely subtracts n from the scale.
  • If n is negative, the call is equivalent to movePointLeft(-n).

The BigDecimal returned by this call has value (this × 10n) and scale max(this.scale()-n, 0).

Syntax:

Parameter:

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

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 right.

Example 1

Test it Now

Output:

Final result after 3 move point right =123230  

Example 2

Test it Now

Output:

Final result after 4 move point right =5345440000  

Example 3

Test it Now

Output:

Final result after -2 move point right =5345.44  

Example 4

Test it Now

Output:

Final result after -6 move point right =0.0005341254  

Next TopicJava BigDecimal

You may also like