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).

Please change your display name to conform with our JavaRanch Naming Policy. You can change it via the My Profile link. Otherwise we will suspend your account. Thanks -Barry

Im' using an array of boolean[] to hold my binaries. I have Read somewhere that boolean types are internally optimized in java.but I don't know why & how.. can you shed some light on this issue ?

I also have another question regarding non-negative binaries operations : How the shift right work for non-negative binaries ? for exple : 1001 shiftRight(6) = ? 1001 shiftRight(2) = ?

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.