Reputation: 1141
I am working with a very large input (trying to solve Next Palindrome problem in SPOJ). I need to compare large numbers and find out which is larger.All this without using BigInteger class other i could i have simply parsed BigInteger from the string and compared to get a result.
I tried string.compare(a,b) but the outputs produced suggest that it doesnt support sorting "numeric strings"
Upvotes: 1
Views: 162
Reputation: 34591
shorterString = shorterString.PadLeft(longerString.Length, '0');
Update: I assumed that the numbers are integers. If they can be floating-point/decimal, then the algorithm will not be as simple.
Upvotes: 3