bitwise and dual ?
This commit is contained in:
parent
34ee2fb962
commit
f4f3471c49
|
@ -2,9 +2,6 @@
|
||||||
|
|
||||||
rm *.out
|
rm *.out
|
||||||
|
|
||||||
clang++-6.0 -std=c++14 -I../helpers/ -o limits.out limits_println.cpp
|
|
||||||
clang++-6.0 -std=c++14 -I../helpers/ -o println.out printlnDemo.cpp
|
|
||||||
|
|
||||||
clang++-6.0 -std=c++14 main_02_MENT.cpp
|
clang++-6.0 -std=c++14 main_02_MENT.cpp
|
||||||
|
|
||||||
./a.out
|
./a.out
|
||||||
|
|
BIN
02_MENT/a.out
BIN
02_MENT/a.out
Binary file not shown.
Binary file not shown.
|
@ -10,6 +10,8 @@ struct PascalString{
|
||||||
char characters[256]; // chars of some character string
|
char characters[256]; // chars of some character string
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char cStringArea[1024];
|
||||||
|
|
||||||
int hexDigitToInt(char hexDigit) {
|
int hexDigitToInt(char hexDigit) {
|
||||||
int value = 0;
|
int value = 0;
|
||||||
|
|
||||||
|
@ -53,12 +55,12 @@ PascalString intToDual(int n) {
|
||||||
char intToHexChar(int n) {
|
char intToHexChar(int n) {
|
||||||
if(n > 9) {
|
if(n > 9) {
|
||||||
switch(n) {
|
switch(n) {
|
||||||
case 10: return 'A'; break;
|
case 10: return 'A';
|
||||||
case 11: return 'B'; break;
|
case 11: return 'B';
|
||||||
case 12: return 'C'; break;
|
case 12: return 'C';
|
||||||
case 13: return 'D'; break;
|
case 13: return 'D';
|
||||||
case 14: return 'E'; break;
|
case 14: return 'E';
|
||||||
case 15: return 'F'; break;
|
case 15: return 'F';
|
||||||
default: return 'X';
|
default: return 'X';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,13 +85,21 @@ PascalString bitwiseDualAnd(PascalString a, PascalString b) {
|
||||||
PascalString result = {longString.length, '0'};
|
PascalString result = {longString.length, '0'};
|
||||||
|
|
||||||
for(int i = longString.length; i >= 0; --i) {
|
for(int i = longString.length; i >= 0; --i) {
|
||||||
if(shortString.characters[i] == '1' && longString.characters[i] == '1') result.characters[i] = '1';
|
if(shortString.length < i) result.characters[i] = longString.characters[i];
|
||||||
else result.characters[i] = '0';
|
result.characters[i] = longString.characters[i] & shortString.characters[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PascalString bitwiseHexAnd(PascalString a, PascalString b) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int to_c_string(PascalString s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv, char** envp) {
|
int main(int argc, char** argv, char** envp) {
|
||||||
|
|
||||||
PascalString s = {3, '1', '0', '0'};
|
PascalString s = {3, '1', '0', '0'};
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue