Results 1 to 4 of 4

Thread: Algorithm to count in binary

  1. #1
    Join Date
    Apr 2009
    Posts
    87

    Algorithm to count in binary

    hi,
    To get back to programming I decided to create a small program that "accounts" in binary. I am currently developing an algorithm on paper yet, but a troubling me greatly. I explain:
    0001 = The block number is, we modify it to become zero and completes the lower value.
    0010 = There is still a zero, it fulfills.
    0011 = There is new block, it will reset everything and then fills the lower value.
    0100 = There are two zeros, one meets the right-most.
    0101 = The problem comes from here, how to understand it must then complete the value in this way before: 0110.

    The technique I wanted to use that manipulate an array of length 4 for the moment, I can count to 15 yet.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Algorithm to count in binary

    I would say you, rethink your algorithm.

    You could instead simply add 1 to the right completely. Then you verified cases by case. If your number is bigger than 1, you put it back to 0 and keep the rest that you added to the next box. If the box becomes larger than 1 ... and so on. By adding an operation, you could smoothly and added binary. And adding a parameter, you can add in all the basics.

  3. #3
    Join Date
    Apr 2009
    Posts
    87

    Re: Algorithm to count in binary

    I did not quite understand the art. If I understand this is how it works:
    0001
    * Verification Number *
    (Not on) are added one at last
    0002
    * Verification Number *
    * It removes the 2 and replaces it with a 0 to 1 prior to the lower value *
    0010
    But I still think the same block in place. You could tell me what if I'm wrong?

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    Re: Algorithm to count in binary

    Addition in binary is a simple Boolean logic. To implement an adder (educationally) better to go through the principles of logic gates. This is what the ALU (arithmetic logic unit) of your processor.

Similar Threads

  1. Need some update on Google Algorithm
    By Hymavath in forum Technology & Internet
    Replies: 7
    Last Post: 14-09-2011, 04:01 PM
  2. Replies: 6
    Last Post: 25-02-2011, 10:40 AM
  3. Algorithm for counting number of nodes in a binary tree
    By anithachacko in forum Software Development
    Replies: 1
    Last Post: 20-04-2010, 01:20 PM
  4. DES ALGORITHM in C Language
    By sayanmaji in forum Software Development
    Replies: 2
    Last Post: 21-03-2010, 11:23 AM
  5. How to Count nodes in Binary Tree ?
    By Harshini in forum Software Development
    Replies: 4
    Last Post: 23-04-2009, 10:54 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,144,254.18687 seconds with 16 queries