Example usage for java.math BigDecimal plus

List of usage examples for java.math BigDecimal plus

Introduction

In this page you can find the example usage for java.math BigDecimal plus.

Prototype

public BigDecimal plus(MathContext mc) 

Source Link

Document

Returns a BigDecimal whose value is (+this) , with rounding according to the context settings.

Usage

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("-333.3454");

    MathContext mc = new MathContext(4); // 4 precision

    // perform plus on bg1 using mc
    BigDecimal bg2 = bg1.plus(mc);

    System.out.println(bg2);//from   w w  w  . j  a v  a  2s .  c o m
}