Hi all , suppose I have two arbitrary lenght binary numbers (could be very large binaries). exple : 1000111 & 11111110001
is it possible to compare them using only there 0s & 1s representations. i.e I don't want to convert them to base 10 & compare them (probably using BigInteger). what I'm looking for is an algorithm that compares 1000111 & 11111110001 only using there 0s & 1s sequences. If this is possible how can I implement it ? please help (this is urgent).
How are you getting your binaries? If you have strings, you can compare length (after trimming leading '0's). The longer is larger. If they are the same length, compare from left to right. The first time one is '1' and the other is '0', the one with the '1' is larger. They are equal if you get to the last bit and they are also the same.
As to your second question, you simply need to add '0's to the left side of your representation, and drop the right bits. Once again, it will depend on how you are representing the bits.