Created
December 21, 2020 14:56
-
-
Save adimiti/a2883f45537a827c7d05132fc246e7e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| int printTabNumber(int x) | |
| { | |
| uint32_t c = ((x<0?'-':' ') << 8) | 0x20UL; | |
| uint32_t s[3] = {0x20202020UL, 0x20202020UL, c}; | |
| int i; | |
| union | |
| { | |
| char b[sizeof(s)]; | |
| uint32_t w[3]; | |
| } buff; | |
| buff.w[0] = s[0]; | |
| buff.w[1] = s[1]; | |
| buff.w[2] = s[2]; | |
| x *= 2 * (x >= 0) - 1; | |
| i = (x>9) + (x>99) + (x>999) + (x>9999) + (x>99999); | |
| fprintf(stderr, "x = %d i = %d [%s]\n", x, i, &(buff.b[i])); | |
| fprintf(stderr, "s = %X %X %X\n", s[0], s[1], s[2]); | |
| fprintf(stderr, "w = %X %X %X\n", buff.w[0], buff.w[1], buff.w[2]); | |
| printf("[%s%d]\n", &buff.b[i], x); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment