MP_02 intToDual
This commit is contained in:
parent
6b0d32e796
commit
81222a26f9
BIN
01_ENV/a.out
BIN
01_ENV/a.out
Binary file not shown.
BIN
01_ENV/func1.o
BIN
01_ENV/func1.o
Binary file not shown.
BIN
01_ENV/main.o
BIN
01_ENV/main.o
Binary file not shown.
BIN
02_MENT/a.out
BIN
02_MENT/a.out
Binary file not shown.
Binary file not shown.
|
@ -40,11 +40,22 @@ void printPascalString(PascalString s) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int intToDual(int n) {
|
PascalString intToDual(int n) {
|
||||||
|
|
||||||
|
int i = std::to_string(n).length() * 4;
|
||||||
|
PascalString string = {i};
|
||||||
|
while(n >= 1) {
|
||||||
|
string.characters[i] = (n % 2) + '0';
|
||||||
|
n = n / 2;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
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'};
|
||||||
PascalString s2 = {4, 'f', 'f', 'f', 'f'};
|
PascalString s2 = {4, 'f', 'f', 'f', 'f'};
|
||||||
println(hexStringToInt(s));
|
println(hexStringToInt(s));
|
||||||
|
@ -64,6 +75,8 @@ int main(int argc, char** argv, char** envp) {
|
||||||
|
|
||||||
println(controlRegister);
|
println(controlRegister);
|
||||||
|
|
||||||
|
printPascalString(intToDual(41));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue