We’d like to remind Forumites to please avoid political debate on the Forum.

This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.

📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!
The Forum now has a brand new text editor, adding a bunch of handy features to use when creating posts. Read more in our how-to guide

binary code :?

im trying to get my head around binary code (for ip addresses), hate anything at all mathematical.
i'm ok changing the binary code to a number.
say 11010111 is 215. (128+64+0+16+0+4+2+1) but i cant work it out the other way. for example, how would i know what the binary is for 239?

its for an exam tomorrow. help would be much appreciated!
What's it going to be, eh?

Comments

  • xio
    xio Posts: 35 Forumite
    Basically subtract the largest power of two from the number, and keep going...

    eg..

    239 - 128 = 111 (1)
    111 - 64 = 47 (1)
    47 - 32 = 15 (1)
    15 - 16 = (not possible therefore 0)
    15 - 8 = 7 (1)
    7 - 4 = 3 (1)
    3 - 2 = 1 (1)
    1 - 1 = 0 (1)

    so 239 = 11101111
    This is not a signature...
  • superscaper
    superscaper Posts: 13,369 Forumite
    Part of the Furniture 10,000 Posts Combo Breaker
    Xio's right, that's how I do it. Starting with largest binary, mark it as 1 for every number you can successfully subtract until you get down to 1.
    "She is quite the oddball. Did you notice how she didn't even get excited when she saw this original ZX-81?"
    Moss
  • keep dividing by 2 and note the remainder

    http://www.groovyweb.uklinux.net/index.php?page_name=how%20to%20convert%20binary%20to%20decimal

    or line up in a

    1024 512 256 128 64 32 16 8 4 2 u
    Ever get the feeling you are wasting your time? :rolleyes:
  • bat999
    bat999 Posts: 1,951 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Combo Breaker
    Hi TeaBoy

    If you're using Windows...

    Open up the Calculator (It's in Accessories)
    Click 'View'
    Click 'Scientific'
    Click the 'Dec' radio button
    Enter your decimal number
    Click the 'Bin' radio button
    Sorted
    :cool:

    ps I know you won't be able to take your pc into the exam, but it might help to check your answers while practicing.
    Never interrupt your enemy when he is making a mistake.
  • TeaBoy_2
    TeaBoy_2 Posts: 408 Forumite
    oh yeah, of course! thanks very much for the replies. makes sense now.
    What's it going to be, eh?
  • ariba10
    ariba10 Posts: 5,432 Forumite
    Part of the Furniture 1,000 Posts Combo Breaker
    There used to be a signature on here a few months back.

    "There are 10 types of people. Those who understand binary and those who do not"
    I used to be indecisive but now I am not sure.
  • TeaBoy_2
    TeaBoy_2 Posts: 408 Forumite
    i'm one of those who don't. i've spent all day trying to answer last years paper with the use of the internet and all my notes!! still struggling! god help me tomorrow.
    What's it going to be, eh?
  • DrSmutt
    DrSmutt Posts: 240 Forumite
    albertross wrote:
    keep dividing by 2 and note the remainder

    http://www.groovyweb.uklinux.net/index.php?page_name=how%20to%20convert%20binary%20to%20decimal

    or line up in a

    1024 512 256 128 64 32 16 8 4 2 u

    This is the way Ive done it for years. Doing it this way will also help with dec to hex or hex to dec.

    a hex example

    number = 2C4F

    32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1
    0 0 1 1 1 1 0 0 0 1 0 0 1 1 1 1
  • lee634
    lee634 Posts: 1,030 Forumite
    DrSmutt wrote:
    This is the way Ive done it for years. Doing it this way will also help with dec to hex or hex to dec.

    a hex example

    number = 2C4F

    32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1
    0 0 1 1 1 1 0 0 0 1 0 0 1 1 1 1

    Hopefully you were just jotting down binary numbers as 2C4f in binary is actually 2 C 4 F
    10 1100 0100 1111
  • DrSmutt
    DrSmutt Posts: 240 Forumite
    oops didnt double check it.
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 353.5K Banking & Borrowing
  • 254.2K Reduce Debt & Boost Income
  • 455.1K Spending & Discounts
  • 246.6K Work, Benefits & Business
  • 603K Mortgages, Homes & Bills
  • 178.1K Life & Family
  • 260.6K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16K Discuss & Feedback
  • 37.7K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.