Java BigDecimal negate() methodThe negate() method of java BigDecimal class is used to obtain a BigDecimal whose value is the negated value (-this) of the BigDecimal with which it is used. Syntax:Parameter:mc: the context to use. Exception:ArithmeticException- if the result is inexact but the rounding mode is UNNECESSARY, the it throws exception: Returns:It returns -this(negated BigDecimal value), rounded as necessary. Example 1Test it NowOutput: Negated value of 5656 is = -5656 Example 2Test it NowOutput: Negated value of -152207 is = 152207 Example 3Test it NowOutput: Negated value of -18.5414 rounded by 4 is = 18.54 Example 4Test it NowOutput: Negated value of -178901456.68431 rounded by 16 is = 178901456.68431 Next TopicJava BigDecimal |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India