![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
Found 9326 Articles for Object Oriented Programming
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
Let us apply the following operations on BigInteger using the in-built methods in Java.Addition: add() method Subtraction: subtract() method Multiplication: multiply() method Division: divide() methodLet us create three BigInteger objects.BigInteger one = new BigInteger("98765432123456789"); BigInteger two = new BigInteger("94353687526754387"); BigInteger three = new BigInteger("96489687526737667");Apply mathematical operations on them.one = one.add(two); System.out.println("Addition Operation = " + one); one = one.multiply(two); System.out.println("Multiplication Operation = " + one);The following is an example −Example Live Demoimport java.math.BigInteger; public class Main { public static void main(String[] args) { BigInteger one = new BigInteger("98765432123456789"); ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
858 Views
First, create a BigInteger.BigInteger val = new BigInteger("198");Let us convert it to Binary, with radix as 2.val.toString(2);Convert it to Octal, with radix as 8.val.toString(8);Convert it to HexaDecimal, with radix as 16.val.toString(16);The following is an example −Example Live Demoimport java.math.BigInteger; public class Main { public static void main(String[] args) { BigInteger val = new BigInteger("198"); System.out.println("Value: " + val); // binary System.out.println("Converted to Binary: " + val.toString(2)); // octal ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
185 Views
Let us set a radix here as.// radix int r = 32;Include the radix here as a BigInteger constructor.BigInteger one = new BigInteger("vv", r);Now get its string representation −String strResult = one.toString(radix);The following is an example −Example Live Demoimport java.math.*; public class Demo { public static void main(String[] args) { // radix int r = 32; BigInteger one = new BigInteger("vv", r); String strResult = one.toString(r); System.out.println(strResult); } }Outputvv
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
Set a BigInteger object.BigInteger one;Now, create a ByteArray −byte byteArr[] = new byte[] { 0x1, 0x00, 0x00 }; one = new BigInteger(byteArr);For Decimal, we have used toString() method without any parameter value.String strResult = one.toString();The following is an example −Example Live Demoimport java.math.*; public class Demo { public static void main(String[] args) { BigInteger one; // ByteArray byte byteArr[] = new byte[] { 0x1, 0x00, 0x00 }; one = new BigInteger(byteArr); // Decimal String strResult = one.toString(); System.out.println("ByteArray to Decimal = "+strResult); } }OutputByteArray to Decimal = 65536
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
451 Views
Set a BigInteger object.BigInteger one;Now, create a ByteArray.byte byteArr[] = new byte[] { 0x1, 0x00, 0x00 }; one = new BigInteger(byteArr);For Octal, we have used 8 as the toString() method parameter.String strResult = one.toString(8);The following is an example −Example Live Demoimport java.math.*; public class Demo { public static void main(String[] args) { BigInteger one; // ByteArray byte byteArr[] = new byte[] { 0x1, 0x00, 0x00 }; one = new BigInteger(byteArr); // Octal String strResult = one.toString(8); System.out.println("ByteArray to Octal = "+strResult); } }OutputByteArray to Octal = 200000
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
3K+ Views
Set a BigInteger object.BigInteger one;Now, create a ByteArray.byte byteArr[] = new byte[] { 0x1, 0x00, 0x00 }; one = new BigInteger(byteArr);For Binary, we have used 2 as the toString() method parameter.String strResult = one.toString(2);The following is an example −Example Live Demoimport java.math.*; public class Demo { public static void main(String[] args) { // BigInteger object BigInteger one; byte byteArr[] = new byte[] { 0x1, 0x00, 0x00 }; one = new BigInteger(byteArr); String strResult = one.toString(2); System.out.println("ByteArray to Binary = "+strResult); } }OutputByteArray to Binary = 10000000000000000
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
195 Views
Firstly, take two BigInteger objects and set values.BigInteger one, two; one = new BigInteger("99");Now, parse BigInteger object “two” into Octal.two = new BigInteger("1100", 8); String str = two.toString(8);Above, we have used the following constructor. Here, radix is set as 8 for Octal. for both BigInteger constructor and toString() method.BigInteger(String val, int radix)This constructor is used to translate the String representation of a BigInteger in the specified radix into a BigInteger.The following is an example −Example Live Demoimport java.math.*; public class Demo { public static void main(String[] args) { BigInteger one, two; one = new ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
Firstly, take two BigInteger objects and set values.BigInteger one, two; one = new BigInteger("99"); two = new BigInteger("978");Now, parse BigInteger object “two” into Binary.two = new BigInteger("1111010010", 2); String str = two.toString(2);Above, we have used the following constructor. Here, radix is set as 2 for Binary for both BigInteger constructor and toString() method.BigInteger(String val, int radix)This constructor is used to translate the String representation of a BigInteger in the specified radix into a BigInteger.The following is an example −Example Live Demoimport java.math.*; public class Demo { public static void main(String[] args) { BigInteger one, two; ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
To parse the hexadecimal string to create BigInteger, use the following BigInteger constructor and set the radix as 16 for Hexadecimal.BigInteger(String val, int radix)This constructor is used to translate the String representation of a BigInteger in the specified radix into a BigInteger.In the below example, we have set the BigInteger and radix is set as 16 −Example Live Demoimport java.math.*; public class Demo { public static void main(String[] args) { BigInteger one, two; String hexStr = "290f98"; one = new BigInteger("250"); // parsing two = ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
233 Views
To parse the decimal string to create BigInteger, just set the decimal string in the BigInteger.Here is our BigInteger.BigInteger one; String decStr = "687879"; one = new BigInteger(decStr);Let us see another example −Example Live Demoimport java.math.*; public class Demo { public static void main(String[] args) { BigInteger one, two; String decStr = "4373427"; one = new BigInteger("250"); two = new BigInteger(decStr); System.out.println("Result (BigInteger) : " +one); System.out.println("Result (Parsing Decimal String) : " +two); } }OutputResult (BigInteger) : 250 Result (Parsing Decimal String) : 4373427