Skip to content

Instantly share code, notes, and snippets.

@ReticentIris
Created March 7, 2016 04:12
Show Gist options
  • Save ReticentIris/bd137d1ca8d93de9eb61 to your computer and use it in GitHub Desktop.
Save ReticentIris/bd137d1ca8d93de9eb61 to your computer and use it in GitHub Desktop.
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