Odd programming request

Discussion in 'Mac Programming' started by CrackedButter, Apr 23, 2008.

  1. CrackedButter macrumors 68040

    CrackedButter

    Joined:
    Jan 15, 2003
    Location:
    51st State of America
    #1
    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.
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    I'll do you one better, here's the code to do it for you:

    Code:
    #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
     
  3. Darsh macrumors member

    Joined:
    Apr 14, 2008
  4. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #4
  5. AlmostThere macrumors 6502a

    #5
    And nobody has discussed the required character encoding!
     
  6. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #6
    I was going to ask ASCII or EBDIC, but thought better of it. Plus it was easier to write w/ ASCII =).

    -Lee
     
  7. Sayer macrumors 6502a

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #7
    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")?
     
  8. CrackedButter thread starter macrumors 68040

    CrackedButter

    Joined:
    Jan 15, 2003
    Location:
    51st State of America
    #8
    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!

    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.
     

Share This Page