
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Calculate Power on a BigInteger in Java
Use the BigInteger pow() method in Java to calculate the power on a BigInteger.
First, let us create some objects.
BigInteger one, two; one = new BigInteger("5");
Perform the power operation and assign it to the second object −
// power operation two = one.pow(3);
The following is an example −
Example
import java.math.*; public class BigIntegerDemo { public static void main(String[] args) { BigInteger one, two; one = new BigInteger("5"); System.out.println("Actual Value: " +one); // power operation two = one.pow(3); System.out.println("Result: " +two); } }
Output
Actual Value: 5 Negated Value: 125
Advertisements