1package com.tutorialspoint;
2
3import java.math.*;
4
5public class BigDecimalDemo {
6
7 public static void main(String[] args) {
8
9 // create 2 BigDecimal objects
10 BigDecimal bg1, bg2;
11
12 // assign value to bg1
13 bg1 = new BigDecimal("40.1264");
14
15 // assign negate value of bg1 to bg2
16 bg2 = bg1.negate();
17
18 String str = "Negated value of " + bg1 + " is "+ bg2;
19
20 // print bg1 and bg2 values
21 System.out.println( str );
22 }
23}