4 Replies - 26820 Views - Last Post: 18 September 2006 - 06:24 AM Rate Topic: -----

#1 smirky06  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 17-September 06

how to convert ascii to binary

Posted 17 September 2006 - 07:47 AM

i need help on this guys.. what should i do?.. get the binary equivalent of every character?... then use a lot of AND and OR?... thanks in advance..
Is This A Good Question/Topic? 0
  • +

Replies To: how to convert ascii to binary

#2 William_Wilson  Icon User is offline

  • lost in compilation
  • member icon

Reputation: 204
  • View blog
  • Posts: 4,807
  • Joined: 23-December 05

Re: how to convert ascii to binary

Posted 17 September 2006 - 09:01 AM

mod (%) 2 is your best friend right here, get the ascii value for the letter, and then mod it by 2 to determine if the value is a 0 or 1... without any code supplied i will not be any more specific.
Was This Post Helpful? 0
  • +
  • -

#3 DeeViLiSh  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 175
  • Joined: 25-July 06

Re: how to convert ascii to binary

Posted 17 September 2006 - 09:01 AM

I don't get your question, is it a question of esthetics or how the program is like?

Look at the Code Snippets Function on how to convert values into binary.
Was This Post Helpful? 0
  • +
  • -

#4 William_Wilson  Icon User is offline

  • lost in compilation
  • member icon

Reputation: 204
  • View blog
  • Posts: 4,807
  • Joined: 23-December 05

Re: how to convert ascii to binary

Posted 17 September 2006 - 10:01 AM

I'm guessing you are looking to convert say:
A = ascii(65), therefore = 1000001
If this is correct, i have written such a code, and many much more complex algorithms to do similar tasks. I find it is a good basis or mid point for encryption. Though the tree structure is much better as it will not require fixed length values :)
Was This Post Helpful? 0
  • +
  • -

#5 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: how to convert ascii to binary

Posted 18 September 2006 - 06:24 AM

I've written many implementations of Decimal to Binary in C as well as Assembly.

You can also use the itoa function like this if you don't want to write the code yourself:
itoa(i,c,b);

i = integer in decimal to be converted
c = character array where binary value will be stored
b = base to be converted....2 in this case



There's a real cool way to do it using recursion....keep trying...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1