- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Negate a BigInteger in Java
Use the BigInteger negate() method in Java to negate a BigInteger.
First, let us create an object −
BigInteger one, two; one = new BigInteger("200");
Negate the above and assign it to the second object −
two = one.negate();
The following is an example −
Example
import java.math.*; public class BigIntegerDemo { public static void main(String[] args) { BigInteger one, two; one = new BigInteger("200"); System.out.println("Actual Value: " +one); // negate two = one.negate(); System.out.println("Negated Value: " +two); } }
Output
Actual Value: 200 Negated Value: -200
- Related Articles
- Negate a BigDecimal value in Java
- Multiply one BigInteger to another BigInteger in Java
- Subtract one BigInteger from another BigInteger in Java
- Divide one BigInteger from another BigInteger in Java
- Shift left in a BigInteger in Java
- Shift right in a BigInteger in Java
- Clear a bit in a BigInteger in Java
- Set a bit for BigInteger in Java
- BigInteger class in Java\n
- Java Program to shift bits in a BigInteger
- Calculate the power on a BigInteger in Java
- Java Program to flip a bit in a BigInteger
- Create BigInteger via string in Java
- Working with BigInteger Values in Java
- Math Operations on BigInteger in Java

Advertisements