X-Git-Url: http://4ch.mooo.com/gitweb/?p=16.git;a=blobdiff_plain;f=src%2Flib%2F16_tail.c;h=9cb0e76997507b1c8dbbb1eb3d7503c98a4877ee;hp=d8f18b9483fa429b79bab5705ae0e653e9b438af;hb=f888d29c0ceaa48568b15f3269df70e6498c9dbc;hpb=40badd0143ad830bd4d873acb9a836f191cc6d57 diff --git a/src/lib/16_tail.c b/src/lib/16_tail.c index d8f18b94..9cb0e769 100755 --- a/src/lib/16_tail.c +++ b/src/lib/16_tail.c @@ -792,101 +792,3 @@ void turboXT(byte bakapee) } } #endif - -//from https://stackoverflow.com/questions/18327439/printing-binary-representation-of-a-char-in-c -const char *word_to_binary(int x) -{ - static char b[17]; - int z; - - b[0] = '\0'; - for (z = 256; z > 0; z >>= 1) - { -/// printf(" z=%u b=%u x=%u\n", z, b, x); - strcat(b, ((x & z) == z) ? "1" : "0"); - } - return b; -} - -const char *byte_to_binary(int x) -{ - static char b[9]; - int z; - - b[0] = '\0'; - for (z = 128; z > 0; z >>= 1) - { - strcat(b, ((x & z) == z) ? "1" : "0"); - } - return b; -} - -const char *nibble_to_binary(int x) -{ - static char b[9]; - int z; - - b[0] = '\0'; - for (z = 8; z > 0; z >>= 1) - { - strcat(b, ((x & z) == z) ? "1" : "0"); - } - return b; -} - -const char *boolean_to_binary(int x) -{ - static char b[3]; - int z; - - b[0] = '\0'; - for (z = 1; z > 0; z >>= 1) - { - strcat(b, ((x & z) == z) ? "1" : "0"); - } - return b; -} - -void wordtest() -{ - word pee; - printf("wordtest\n"); - /* word to binary string */ - for(pee=0;pee<280;pee++) - printf(" %u %s\n", pee, word_to_binary(pee)); - printf(" sizeof(word)=%s\n", word_to_binary(sizeof(word))); - printf("end of word test\n"); -} - -void bytetest() -{ - byte pee; - printf("bytetest\n"); - /* byte to binary string */ - for(pee=0;pee<18;pee++) - printf(" %u %s\n", pee, byte_to_binary(pee)); - printf(" sizeof(byte)=%s\n", byte_to_binary(sizeof(byte))); - printf("end of byte test\n"); -} - -void nibbletest() -{ - nibble pee; - printf("nibbletest\n"); - /* nibble to binary string */ - for(pee=0;pee<18;pee++) - printf(" %u %s\n", pee, nibble_to_binary(pee)); - printf(" sizeof(nibble)=%s\n", nibble_to_binary(sizeof(nibble))); - printf("end of nibble test\n"); -} - -void booleantest() -{ - boolean pee; - printf("booleantest\n"); - /* boolean to binary string */ - for(pee=0;pee<4;pee++) - printf(" %u %s\n", pee, boolean_to_binary(pee)); - printf(" sizeof(boolean)=%s\n", boolean_to_binary(sizeof(boolean))); - printf("end of boolean test\n"); -}