Fix KatolaZ bug and remove octal output. - int2bit - Convert integer to funny way. HTML git clone git://bitreich.org/int2bit git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/int2bit DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit a03a0d642d21e0fb5a287447d223de7e3353eb36 DIR parent 3e15a8787c1325acff205c4a919e685683622907 HTML Author: Christoph Lohmann <20h@r-36.net> Date: Sat, 4 Jul 2020 23:22:23 +0200 Fix KatolaZ bug and remove octal output. Octal output is flawed because it has many notations. Diffstat: M int2bit.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) --- DIR diff --git a/int2bit.c b/int2bit.c @@ -24,9 +24,10 @@ main(int argc, char *argv[]) in = atoi(argv[1]); srand(in); - for (hasprint = 0, hexprint = 0, i = sizeof(in) * 8; i > 0; i--) { + for (hasprint = 0, hexprint = 0, i = (sizeof(in) * 8)-1; i >= 0; i--) { if (in & (1<<i)) { /* Decide about next step. */ + /* printf("\nint = %d\n", (1<<i)); */ switch (rand() % 3) { case 0: /* print shift */ @@ -41,13 +42,8 @@ main(int argc, char *argv[]) if (hasprint) printf("|"); hexprint |= (1<<i); - if (rand() % 2) { - /* octal */ - printf("0o%o", hexprint); - } else { - /* hexadecimal */ - printf("0x%x", hexprint); - } + /* hexadecimal */ + printf("0x%x", hexprint); hexprint = 0; hasprint = 1; break;