Created
March 7, 2016 04:12
-
-
Save ReticentIris/bd137d1ca8d93de9eb61 to your computer and use it in GitHub Desktop.
This file contains 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
int get_bit_at(int x, int index){ | |
return (x & (1 << index)) >> index | |
} | |
void int_to_ascii(int x, char* str){ | |
int result = 0 | |
for(int index = 0; index < 32; index++){ | |
if(get_bit_at(x, index) == 1){ | |
result |= 1 << x | |
} | |
} | |
sprintf(str, "%d", result) | |
} | |
void double_to_ascii(int x, char* str){ | |
int result = 0 | |
for(int index = 0; index < 32; index++){ | |
if(get_bit_at(x, index) == 1){ | |
result |= 1 << x | |
} | |
} | |
sprintf(str, "%f", result) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment