Closed Thread
Results 1 to 4 of 4

Thread: Code Conversion....

  1. #1
    stephen0606 is offline Newbie
    Join Date
    Sep 2007
    Posts
    8
    Rep Power
    0

    Question Code Conversion....

    Does c++ gt a special function for conversion between decimal to binary or decimal to hexadecimal and others???

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Jordan Guest
    Decimal to binary is a simple enough equation that you can create it yourself. Divide your decimal number by 2 and take the remainder. You can do this using the modulus (%) operator. Keep doing this until the decimal number = 0.

    Code:
    (int) BinaryMod = decimalNumber %2;
    (String) BinaryDisplay += BinaryMod;
    decimalNumber / 2;
    In .NET you can use:

    Code:
     Convert.ToString(DecimalValue, 2).PadLeft(8, "0")
    Where DecimalValue is your decimal number and 2 is your base. Using that function you can convert to any base.

  4. #3
    stephen0606 is offline Newbie
    Join Date
    Sep 2007
    Posts
    8
    Rep Power
    0

    Question

    thanks jordan, for decimal and octo i done it edi...but for hexadecimal....i still dunno how to convert d 10,11,12....to alphabet...i just can manage to show their ASCII code...how to do it????

  5. #4
    Jordan Guest
    You need to convert the base to 16 for hexadecimal. I found some C# code which does this and you should be able to convert it to Manage C++ code very easy: How to convert string to hexadecimal and vice versa

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. conversion from c to c++
    By ogopa in forum C and C++
    Replies: 3
    Last Post: 07-26-2011, 08:30 AM
  2. Conversion
    By mr mike in forum C and C++
    Replies: 4
    Last Post: 03-28-2011, 12:13 AM
  3. Please help me about conversion to structure
    By chekers in forum C and C++
    Replies: 6
    Last Post: 10-21-2009, 10:32 AM
  4. C++ to assembly conversion
    By Kaishain in forum C and C++
    Replies: 5
    Last Post: 07-17-2009, 09:16 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