aboutsummaryrefslogtreecommitdiff
path: root/Semestr 4/ask/zadanie1
diff options
context:
space:
mode:
authorFranciszek Malinka <franciszek.malinka@gmail.com>2021-04-06 14:28:27 +0200
committerFranciszek Malinka <franciszek.malinka@gmail.com>2021-04-06 14:28:27 +0200
commitf64f7de412dd06affb0670831bdd117bde33a192 (patch)
tree398c4bb6f7fc88deb54104b4faab34f4982abf30 /Semestr 4/ask/zadanie1
parent872fff966e7a069fe0e40e76f7bc996790521ee0 (diff)
Update
Diffstat (limited to 'Semestr 4/ask/zadanie1')
-rw-r--r--Semestr 4/ask/zadanie1/rozw.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/Semestr 4/ask/zadanie1/rozw.c b/Semestr 4/ask/zadanie1/rozw.c
new file mode 100644
index 0000000..068a268
--- /dev/null
+++ b/Semestr 4/ask/zadanie1/rozw.c
@@ -0,0 +1,21 @@
+#include <stdint.h>
+#include <stdio.h>
+
+const uint64_t C[] = {
+ 0x5555555555555555LL,
+ 0x3333333333333333LL,
+ 0x0f0f0f0f0f0f0f0fLL,
+ 0x00ff00ff00ff00ffLL,
+ 0x0000ffff0000ffffLL,
+ 0x00000000ffffffffLL
+};
+
+uint64_t revbits(uint64_t x) {
+ x = ((x & C[0]) << 1) | ((x >> 1) & C[0]);
+ x = ((x & C[1]) << 2) | ((x >> 2) & C[1]);
+ x = ((x & C[2]) << 4) | ((x >> 4) & C[2]);
+ x = ((x & C[3]) << 8) | ((x >> 8) & C[3]);
+ x = ((x & C[4]) << 16) | ((x >> 16) & C[4]);
+ x = ((x & C[5]) << 32) | ((x >> 32) & C[5]);
+ return x;
+} \ No newline at end of file