Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Converting decimal to binary?

  • 12-12-2006 3:14pm
    #1
    Registered Users, Registered Users 2 Posts: 9,844 ✭✭✭


    Hi folks,

    I am working away on some questions that will no doubt come up in an exam next year.

    The first is converting a decimal number to a binary number.

    Lets say 221:

    221/2 = 110 remainder = 1
    110/2 = 55 remainder = 0
    55/2 = 27 remainder = 1
    27/2 = 13 remainder = 1
    13/2 = 6 remainder = 1
    6/2 = 3 remainder = 0
    3/2 = 1 remainder = 1
    1/2 = 1 remainder = ???

    Now I know you reverse the numbers to get the binary but I am not sure what the first number is

    ?1011101

    Help meeeeeeeeeeeeeeeeeeee! :(


Comments

  • Registered Users, Registered Users 2 Posts: 273 ✭✭stipey


    I didn't read this fully but this might help...

    http://en.wikipedia.org/wiki/Binary_numeral_system#Decimal


  • Closed Accounts Posts: 999 ✭✭✭Noelie


    if it's a odd decimal number the last digit must always be a '1'


  • Registered Users, Registered Users 2 Posts: 9,844 ✭✭✭py2006


    Noelie wrote:
    if it's a odd decimal number the last digit must always be a '1'

    Ah I see! I went to a site that automatically converts them and it had a 1 there. I couldn't figure out why!

    Thanks


  • Registered Users, Registered Users 2 Posts: 9,844 ✭✭✭py2006


    What about the reverse? Binary to decimal?

    1010100


  • Closed Accounts Posts: 999 ✭✭✭Noelie


    is that read left to right or right to left? i could never remember
    but i make that out to be 21


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 9,844 ✭✭✭py2006


    Noelie wrote:
    is that read left to right or right to left? i could never remember
    but i make that out to be 21

    I don't know! I was hoping you could tell me! :D


  • Registered Users, Registered Users 2 Posts: 9,844 ✭✭✭py2006


    py2006 wrote:
    I don't know! I was hoping you could tell me! :D

    I think there answer is actually 84! not sure!


  • Closed Accounts Posts: 999 ✭✭✭Noelie


    well i'm reading it from the left as the lsb, but i could be wrong it's been years since i done any of this stuff.
    the lsb is 1, then 2 then 4, every next bit represents twice the previous so you'd have
    1 2 4 8 16 32 64 128 256 512
    1 0 1 0 1 0 0
    so you add 1 + 4 + 16 and get 21.

    but if the 0 on the rigth is the lsb you get
    1 2 4 8 16 32 64 128 256 512
    0 0 1 0 1 0 1
    which would be 4 + 16 + 64 = 84


  • Registered Users, Registered Users 2 Posts: 9,844 ✭✭✭py2006


    py2006 wrote:
    I don't know! I was hoping you could tell me! :D

    I think there answer is actually 84! not sure!


  • Closed Accounts Posts: 999 ✭✭✭Noelie


    just looked about a little and it's read from right to left, so the lsb is 0, making 84 the correct answer


  • Advertisement
  • Closed Accounts Posts: 3,285 ✭✭✭Smellyirishman


    To go from binary to decimal

    The far right digit it 2^0 or 1,
    the one left to that is 2^1 or 2,
    left of that is 2^2 or 4.
    left of that is 2^3 or 8.
    etc...

    So, if you have 101 as your binary number then 2^0 is "on" and 2^2 is "on" so 1+4 = 5.

    In your example, it's.... nm, check out Noelie's explaination. (I am pretty sure 2^0 is the rightmost bit)


  • Closed Accounts Posts: 243 ✭✭vallo


    A minor point but can't you check it on your calculator?
    You can do binary, octal, dec, hex conversions on any decent calculator - even the Microsoft(R) calculator can do it.


  • Registered Users, Registered Users 2 Posts: 9,844 ✭✭✭py2006


    vallo wrote:
    A minor point but can't you check it on your calculator?
    You can do binary, octal, dec, hex conversions on any decent calculator - even the Microsoft(R) calculator can do it.

    Yes, but they can't be brought into the exam! :(


  • Registered Users, Registered Users 2 Posts: 4,940 ✭✭✭dingding




  • Registered Users, Registered Users 2 Posts: 16,202 ✭✭✭✭Pherekydes


    py2006 wrote:
    Hi folks,

    1/2 = 1 remainder = ???

    (

    1/2 = 0 remainder 1.

    This is your one mistake. Bí cúramach!


  • Registered Users, Registered Users 2 Posts: 16,202 ✭✭✭✭Pherekydes


    For binary to decimal conversion:

    1011:

    = 1*(2^3) + 0*(2^2) + 1*(2^1) + 1*(2^0)

    = 8 + 0 + 2 + 1

    = 11


    Start on the right. The first bit is two to the power of zero, the next one is two to the power of one and so on.


  • Registered Users, Registered Users 2 Posts: 9,844 ✭✭✭py2006


    Thanks guys! does the symbol ^ mean to power of?


  • Registered Users, Registered Users 2 Posts: 16,202 ✭✭✭✭Pherekydes


    py2006 wrote:
    Thanks guys! does the symbol ^ mean to power of?


    Yes.


Advertisement