und weiter geht der Spaß

This commit is contained in:
Johannes Theiner 2018-04-09 21:22:13 +02:00
parent 37a116cf63
commit b75b7e169a
1 changed files with 7 additions and 2 deletions

View File

@ -80,13 +80,18 @@ PascalString intToHex(int n) {
} }
int getInt(char character) {
if(character == '0') return character;
else return '1';
}
PascalString bitwiseDualAnd(PascalString a, PascalString b) { PascalString bitwiseDualAnd(PascalString a, PascalString b) {
PascalString result = {a.length, '0'}; PascalString result = {a.length, '0'};
for(int i = b.length; i >= 0; --i) { for(int i = b.length; i >= 0; --i) {
if(a.length < i) result.characters[i] = a.characters[i]; if(a.length < i) result.characters[i] = a.characters[i];
println("i: ", i, " ", a.characters[i] & b.characters[i]); println("i: ", i, " ", intToHexChar(getInt(a.characters[i]) & getInt(b.characters[i])));
result.characters[i] = a.characters[i] & b.characters[i]; result.characters[i] = intToHexChar(getInt(a.characters[i]) & getInt(b.characters[i]));
} }
return result; return result;