private static String process(ArrayList imp,String HexStr){ String rem = ""; Long remaind = (long) 0; ArrayList newList = new ArrayList(); Iterator itor = imp.iterator(); while(itor.hasNext()){ String ele = itor.next(); Long num = Long.parseLong(rem+ele); Long quot = num / 16; remaind = num%16; rem = remaind.toString(); if(quot > 0){ newList.add(padString(quot.toString(),16,"0",0)); } }; String hexRem = Long.toHexString(remaind); if(newList.isEmpty()){ return hexRem; } else{ return process(newList,hexRem)+hexRem; } } public static String D2Hex(String dNum){ String tmp = dNum; ArrayList splitNum = new ArrayList(); while(tmp.length() > 16){ String high = tmp.substring(0,tmp.length() - 16); splitNum.add(high); String low = tmp.substring(tmp.length() - 16); tmp = low; } splitNum.add(tmp); return process(splitNum,""); } public static String D2B(String dNum){ String hex = D2Hex(dNum); StringBuilder bin= new StringBuilder(); for(int i =0; i < hex.length(); i ++){ String tmp = Integer.toBinaryString( Integer.parseInt(hex.substring(i,i+1),16)); bin.append(padString(tmp,4,"0",0)); } return bin.toString(); }
Résultat d'un super grand nombre non vérifié 0------>0--->0000 135,9234------>14bd82--->000101001011110110000010 9999,9999,9999, 9999 ------>2386f26fc0ffff--->0010001110000110111100100110111111 0000001111111111111111 1,0000,0000,0000,0000------>2386f2 6fc10 000--->0010001110000110111100100110111111000001000000000000000 9,9999,9999, 9999,9999 ------>16345785d89ffff--->00010110001101000101011110000101110110001001111111111111111 9999,9999,9999,9999,999 9,9999,99 99,9999------>4ee2d6d415b85acef80ffffffff--->010011101110001011010110110101000001010110111000010110101100111011111000000 01111 111111111111111111111111111
Selon le principe de conversion décimal en binaire, simulez la division par 2 et la prise du reste
Il ne devrait pas être trop difficile d'écrire l'algorithme vous-même et de le laisser en arrière-plan pour le traitement
Résultat d'un super grand nombre non vérifié
0------>0--->0000
135,9234------>14bd82--->000101001011110110000010
9999,9999,9999, 9999 ------>2386f26fc0ffff--->0010001110000110111100100110111111 0000001111111111111111
1,0000,0000,0000,0000------>2386f2 6fc10 000--->0010001110000110111100100110111111000001000000000000000
9,9999,9999, 9999,9999 ------>16345785d89ffff--->00010110001101000101011110000101110110001001111111111111111
9999,9999,9999,9999,999 9,9999,99 99,9999------>4ee2d6d415b85acef80ffffffff--->010011101110001011010110110101000001010110111000010110101100111011111000000 01111 111111111111111111111111111
Écrivez ce que vous voulez
Je veux demander, super gros, quelle est sa taille
S'il s'agit uniquement d'un affichage, vous pouvez envisager de le transférer en arrière-plan