0
一些值/編碼解碼此是否有可能進行解碼/編碼本,而不會失去使用360 INT到1字節是否有可能,而不會失去使用360 INT到1字節
進出口目前尋找一種方法來減少一些值360以適應255個字節的最大值。
這是我的嘗試:
public static int getBearing(byte data){
return Integer.parseInt(Integer.toHexString(data & 0xff) , 16) << 1;
}
public static void main(String[] args){
for(int bearing = 0 ; bearing < 360 ; bearing++){
final byte bearingByte = (byte) (bearing >> 1);
System.out.printf("Bit {%s} , Original Bearing {%d} , Decrypted Bearing {%d} \n" , get8Bit(bearingByte) , bearing , getBearing(bearingByte));
}
}
和輸出是:
Bit {00000000} , Original Bearing {0} , Decrypted Bearing {0}
Bit {00000000} , Original Bearing {1} , Decrypted Bearing {0} <-- this should be 1
Bit {00000001} , Original Bearing {2} , Decrypted Bearing {2}
Bit {00000001} , Original Bearing {3} , Decrypted Bearing {2} <-- this should be 3
Bit {00000010} , Original Bearing {4} , Decrypted Bearing {4}
Bit {00000010} , Original Bearing {5} , Decrypted Bearing {4} <-- this should be 5
Bit {00000011} , Original Bearing {6} , Decrypted Bearing {6}
Bit {00000011} , Original Bearing {7} , Decrypted Bearing {6} <-- this should be 7
Bit {00000100} , Original Bearing {8} , Decrypted Bearing {8}
Bit {00000100} , Original Bearing {9} , Decrypted Bearing {8} <-- this should be 8
好像一切都在解密是偶數。
是否有一個公式或詭計,使我不能失去一些價值?
您是否要求是/否回答?因爲它看起來像是我們的[off-topic](http://stackoverflow.com/help/on-topic)列表 – davejal
的第4位,如果可能,請使用解決方案。 – david