decimal to binary conversion

This is a discussion on decimal to binary conversion within the C Programming forums, part of the General Programming Boards category; hi i want to make a program that spits out the binary equivalent of numbers from 0-10000. Any ideas how ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    134

    decimal to binary conversion

    hi i want to make a program that spits out the binary equivalent of numbers from 0-10000. Any ideas how to get started.???

  2. #2
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,156
    Sure, lots of ideas ;-)

    Look into the bit-shift operators << and >> to move individual bits into a usable position (position 0 specifically) and the boolean operators & and | to isolate one bit.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    This question gets posted easily every week. Try searching for it.


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Casual Visitor
    Join Date
    Oct 2001
    Posts
    350
    If you're not up to speed on bit shifting, you can use repeated integral division of the number divided by the Radix. For example, 150: 150 / 2 = 75 with a remainder of 0. The binary representation will come out in reverse order using the remainder values.

    Hey WaltP.
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

  5. #5
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,156
    Originally posted by ronin If you're not up to speed on bit shifting, you can use repeated integral division of the number divided by the Radix. For example, 150: 150 / 2 = 75 with a remainder of 0. The binary representation will come out in reverse order using the remainder values.
    One wonders which is a more confusing response

    Hey WaltP.
    Hey back!!
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 07-04-2008, 12:39 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. binary decimal conversion
    By eerok in forum C Programming
    Replies: 2
    Last Post: 01-24-2006, 08:51 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Decimal to binary conversion help needed
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 02-06-2002, 12:03 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21