![]() |
In Java, long and BigInteger are two different data types used to represent and perform operations on the large integers. In this article we will learn about BigInteger and Long in Java. long in Javalong is a primitive data type in Java used to store 64-bit signed integers.
The long data type is commonly used for integer values that are expected to be larger than the range of int. Syntax:long variableName;
Example of Java longBelow is the implementation of the long in Java are mentioned below:Java
Output
num1 = 1234567890 num2 = 9876543210 sum = 11111111100 difference = 8641975320 product = -6253480962446024716 quotient = 8 BigInteger in JavaBigInteger is a class in Java’s java.math package that represents arbitrary-precision integers.
Syntax :BigInteger num1 = new BigInteger(); Examples of BigIntegerBelow is the implementation of the above method:Java
Output
num1 = 12345678901234567890 num2 = 98765432109876543210 sum = 111111111011111111100 difference = 86419753208641975320 product = 1219326311370217952237463801111263526900 quotient = 8 Difference between long and BigIntegerDifferences between long and BigInterger are mentioned in the table given below:
|
Reffered: https://www.geeksforgeeks.org
Difference Between |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 16 |