From 3312ecae2a3c212cdc74e1b8040cf7dda554044c Mon Sep 17 00:00:00 2001 From: Jakub Adamski Date: Thu, 16 Dec 2021 15:06:37 +0100 Subject: [PATCH] miniprojekt3 --- miniprojekt3/zadania.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 miniprojekt3/zadania.py diff --git a/miniprojekt3/zadania.py b/miniprojekt3/zadania.py new file mode 100644 index 0000000..024c324 --- /dev/null +++ b/miniprojekt3/zadania.py @@ -0,0 +1,21 @@ +# dodawanie hex + +xhex = "ae" +yhex = "11" + +scale = 16 +num_of_bits = 8 + +xbin = bin(int(xhex, scale))[2:].zfill(num_of_bits) +#print(xbin) + +ybin = bin(int(yhex, scale))[2:].zfill(num_of_bits) +#print(ybin) + +result = "" +for idx, b in enumerate(xbin): + result += str(int(b) ^ int(ybin[idx])) + +hexresult = hex(int(result, 2)) + +print(hexresult)