Results 1 to 8 of 8

Thread: 24bit to decimal

  1. #1

    Default 24bit to decimal

    i was wondering how can we convert a 24bit binary no. into a decimal no. using a micro this is becase using a mico we can not do the usual way 2^0+2^1+2^2............one way is to divide no. by 10(1010) and keep the remainder. this works for 8bit nos. but i cant figure it out how to use it for 24bitno.


    asimov

  2. #2
    Administrator T-1000 vikas's Avatar
    Join Date
    Feb 2004
    Location
    Delhi
    Posts
    1,922
    Blog Entries
    14

    Default

    Maybe i did not get the question right but cant u simply shift all the bits into a long itll become a number automatically ( if you are using C )

    Maybe you can explain a little more

  3. #3

    Default 24 bit to decimal

    vikas i am using assembly language for a programme running on 8051(at89s51) which has a 24 bit no. (split into 3-8bit no. stored in 3 registerssay r1 r2 and r3). i want to calc the decimal no. cossesponding to the 24bit binary no. formed by cocatinatinating the 3 registers.
    now do u get the prob?
    asimov

  4. #4
    Administrator T-1000 vikas's Avatar
    Join Date
    Feb 2004
    Location
    Delhi
    Posts
    1,922
    Blog Entries
    14

    Default

    Suppose you are going to store the decimal in a 4 byte memory then simply put the registers at the appropate positions in the memory. Now that 4 byte memory is a long which contains the value in decimal.

  5. #5
    Member Advanced User
    Join Date
    Mar 2006
    Location
    mathura
    Posts
    40

    Default

    Hi,
    can you please elaborate on the problem

  6. #6

    Default Re: 24bit to decimal

    Quote Originally Posted by asimov_18
    i was wondering how can we convert a 24bit binary no. into a decimal no. using a micro this is becase using a mico we can not do the usual way 2^0+2^1+2^2............one way is to divide no. by 10(1010) and keep the remainder. this works for 8bit nos. but i cant figure it out how to use it for 24bitno.


    asimov
    The logic works for any bit number, only the resultant number / string must have sufficient memory allocoted.

    idlebrain

  7. #7

    Default

    vikas i am using assembly language for a programme 640-460 exam running on 8051(at89s51) which has a 24 bit no. (split into 3-8bit 70-271 exam no. stored in 3 registerssay r1 r2 and r3). i want to calc the decimal no. cossespondin 646-230 exam g to the 24bit binary no. formed by cocatinatinating the 3 registers.
    now do u get the prob?

  8. #8

    Default

    HI there are ways and means of doing this. Infact I had found routine at http://www.8052.com/codelib url for my task, I couldn't find the logic for the routine and that why I had put it in this forum. One way of implemnting this is thru the boots algo...serach the google and you will get plenty of posts for booths algo.


    Asimov
    Last edited by asimov_18; 01-02-2010 at 11:19 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •