View Full Version : Odd programming request
CrackedButter
Apr 23, 2008, 11:55 AM
I'm doing a project involving binary code and I want to draw binary code into sand. If I provide the words can anybody translate it back into binary please?
'Destroyer'
'Our Nature'
'Environment'
'Warning'
'Danger'
Here is my first attempt anyway so as to let you in on what I am doing: http://flickr.com/photos/crackedbutter/2385089838/ I also understand that this doesn't make any sense.
lee1210
Apr 23, 2008, 12:19 PM
I'll do you one better, here's the code to do it for you:
#include <stdio.h>
void getbinarystr(char,char[]);
int main(int argc, char *argv[]) {
char singleChar[9];
int len,x;
if(argc < 2) {
printf("Please enter a string to convert\n");
return -1;
}
len = strlen(argv[1]);
for(x = 0; x < len; x++) {
getbinarystr(argv[1][x],singleChar);
printf("%c\t%s\n",argv[1][x],singleChar);
}
return 0;
}
void getbinarystr(char oneChar, char output[9]) {
int x;
for(x = 7;x>=0;x--) {
if((oneChar & (1 << x)) != 0) {
output[7-x]='1';
} else {
output[7-x]='0';
}
}
output[8]=0;
}
Save it to a text file that ends with .c, say tobin.c. Then from the terminal run:
gcc -o tobin tobin.c
./tobin "String to Convert"
The output will be like this:
D 01000100
e 01100101
s 01110011
t 01110100
r 01110010
o 01101111
y 01111001
e 01100101
r 01110010
-Lee
Darsh
Apr 23, 2008, 12:30 PM
http://nickciske.com/tools/binary.php You can do it yourself for any word :)
lee1210
Apr 23, 2008, 12:32 PM
http://nickciske.com/tools/binary.php You can do it yourself for any word :)
C'mon, it's a *programming* forum. What fun is that? =)
AlmostThere
Apr 23, 2008, 01:13 PM
C'mon, it's a *programming* forum.
And nobody has discussed the required character encoding!
lee1210
Apr 23, 2008, 01:21 PM
And nobody has discussed the required character encoding!
I was going to ask ASCII or EBDIC, but thought better of it. Plus it was easier to write w/ ASCII =).
-Lee
Sayer
Apr 23, 2008, 01:50 PM
I guess its supposed to be ironic that you are using a big hunk of plastic and inorganic chemical-based product to do some environmental "art installation" that no one can understand in sand, the basis for computer chips (silicon)?
*sigh*
Why not just take your environment-destroying computer, write the word on the screen and jab it into the beach (where it can pollute the environment for real - like you think it already does by existing, despite the fact you continue to purchase and use them in your own "home")?
CrackedButter
Apr 23, 2008, 03:50 PM
Thanks for everyone who helped me figure out the binary thing. Mighty useful link. I'll let you know how I get on with my 'hello world' idea!
I guess its supposed to be ironic that you are using a big hunk of plastic and inorganic chemical-based product to do some environmental "art installation" that no one can understand in sand, the basis for computer chips (silicon)?
*sigh*
Why not just take your environment-destroying computer, write the word on the screen and jab it into the beach (where it can pollute the environment for real - like you think it already does by existing, despite the fact you continue to purchase and use them in your own "home")?
You've clearly missed the point of this project, is irony all you see?
I'm trying to combine my photographic practice with specific things in technology. Of course only a few people will understand what I am trying to do, you've seen the work for 10 seconds maybe? I've been working on this for 6 months with the theory to back it up. Don't you watch Futurama and understand the 'other' in jokes present in the episodes? There is a point to people doing that and I have a reason for doing it as well.
A computer = binary. So there is no need to use an actual computer (using one would change the dialogue present in the image) never mind that fact that that would be even more wasteful and if I uploaded such a picture of a mac getting trashed I'm sure a thousand mac geeks will be more critical and vocal than how you're being for having done that! :-)
I'd like to add that my lifestyle is one that tries to have as little impact on the environment as much as possible, thanks for taking the time out to judge me though.
Are you a programmer by any chance? If you were you'd understand a few of the images I am going to make, if you aren't wouldn't you want to understand what is being said, after all you sussed that I'm trying to say something.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.