Akshay Sharma Akshay Sharma - 3 months ago 35
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:




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


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.