java - matching different sized strings -


actually went through research docuements , got situation match binary string binary string size uknown ex:

"1110000010001001101011010100010000101101001001010010000101000011"== "1011010111010111111111010101100000000000101111101100011010011011" 

i want result true if string matches significant bits of string

to compare 1 msb, compare first character below:

boolean result = number1.charat(0) == number2.charat(0); 

for multiple msbs, use following code:

int noofmsbs = 8; boolean result = number1.substring(0, noofmsbs - 1).equals(number2.substring(0, noofmsbs - 1)); 

to compare if whole number present msb in string:

boolean result = number2.startswith(number1); 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -