0

i have a Big Decimal like this for example. i want to negative it's value. it has a string.

String a = "65";
BigDecimal example = new BigDecimal(a);
//i want to have (-65)
sorena
  • 3
  • 2

1 Answers1

3

BigDecimal.negate()

String a = "65";
BigDecimal example = new BigDecimal(a);
System.out.println( example.negate() ); // prints -65
sinclair
  • 2,812
  • 4
  • 24
  • 53
  • @sinclair: I'm not sure sorena has seen or understood that yet. – Rudy Velthuis Apr 27 '17 at 09:55
  • @sinclair :DD im really sorry. the moment i was noob and actually i made another account with another email. all of a sudden i just logged in into this account and saw your comment. marked it. sorry for the delay :D – sorena May 08 '18 at 11:31