This commit is contained in:
Johannes Theiner 2018-04-09 22:14:48 +02:00
parent 73e17aae12
commit 1194294d2e
1 changed files with 3 additions and 25 deletions

View File

@ -52,28 +52,6 @@ PascalString intToDual(int n) {
return string;
}
char intToHexChar(int n) {
switch(n) {
case 0: return '0';
case 1: return '1';
case 2: return '2';
case 3: return '3';
case 4: return '4';
case 5: return '5';
case 6: return '6';
case 7: return '7';
case 8: return '8';
case 9: return '9';
case 10: return 'A';
case 11: return 'B';
case 12: return 'C';
case 13: return 'D';
case 14: return 'E';
case 15: return 'F';
default: return 'X';
}
}
PascalString intToHex(int n) {
int i = std::to_string(n).length();
PascalString string = {i};
@ -94,10 +72,10 @@ int getInt(char character) {
PascalString bitwiseDualAnd(PascalString a, PascalString b) {
PascalString result = {a.length, '0'};
for(int i = b.length; i >= 0; --i) {
for(int i = a.length; i >= 0; --i) {
if(a.length < i) result.characters[i] = a.characters[i];
println("i: ", i, " ", intToHexChar(getInt(a.characters[i]) & getInt(b.characters[i])));
result.characters[i] = intToHexChar(getInt(a.characters[i]) & getInt(b.characters[i]));
println("i: ", i, " ", getInt(a.characters[i]) & getInt(b.characters[i]));
result.characters[i] = getInt(a.characters[i]) & getInt(b.characters[i]);
}
return result;