Akshay Sharma Akshay Sharma - 16 days ago 7
Java Question

Compare two large numbers

Two strings representing two numbers have been provided as input. The numbers in the string can be so large that they may not be represented by the Java data type int. The objective is to compare the two numbers and output that number as a string

for example we have to compare:

"874986754789289867753896798679854698798789857387687546456"

and

"98347598375689758967756458678976893478967586857687569874"

which both are out of range of long and int data types in JAVA
and after comparing we have to output that number as a string

Answer

you could start by first looking at each string's length. if one of them is longer and you know they are both unsigned values, the longer string has the bigger number. if they both have the same length, you start comparing the strings char by char starting from left to right. when you found your first bigger digit you conclude that number is bigger.