Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. hex to dec

hex to dec

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    styve
    wrote on last edited by
    #1

    Hi! Having problem by using sprintf. I have the hexadecimal 2B67, and will convert it to decimal by using sprintf. Can someone help me?? I know how to do vice verca.

    P C E 3 Replies Last reply
    0
    • S styve

      Hi! Having problem by using sprintf. I have the hexadecimal 2B67, and will convert it to decimal by using sprintf. Can someone help me?? I know how to do vice verca.

      P Offline
      P Offline
      Prakash Nadar
      wrote on last edited by
      #2

      As far as i know there is no datatype called hexadecimal. What is the actuaal data type wheather its Int, long, or string if its string then you need to convert it to long or int and use the following statemetn printf("%d",nHexNum); or printf("%ld",lHexNum); Which ever fits rite.


      I have lost more blood shaving than on the battlefield - Adolf Hitler

      D 1 Reply Last reply
      0
      • P Prakash Nadar

        As far as i know there is no datatype called hexadecimal. What is the actuaal data type wheather its Int, long, or string if its string then you need to convert it to long or int and use the following statemetn printf("%d",nHexNum); or printf("%ld",lHexNum); Which ever fits rite.


        I have lost more blood shaving than on the battlefield - Adolf Hitler

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Mr.Prakash wrote: As far as i know there is no datatype called hexadecimal. Then what do you call base-16 numbers?


        "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

        P 1 Reply Last reply
        0
        • D David Crow

          Mr.Prakash wrote: As far as i know there is no datatype called hexadecimal. Then what do you call base-16 numbers?


          "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

          P Offline
          P Offline
          Prakash Nadar
          wrote on last edited by
          #4

          humm, is there any data type called base-16 in c/c++????


          I have lost more blood shaving than on the battlefield - Adolf Hitler

          D 1 Reply Last reply
          0
          • P Prakash Nadar

            humm, is there any data type called base-16 in c/c++????


            I have lost more blood shaving than on the battlefield - Adolf Hitler

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            No, but there are base-16 numbers, also known as hexadecimal numbers. Referring back to styve's post, he wanted to convert a base-16 number (hexadecimal) to a base-10 number (decimal).


            "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

            P 1 Reply Last reply
            0
            • D David Crow

              No, but there are base-16 numbers, also known as hexadecimal numbers. Referring back to styve's post, he wanted to convert a base-16 number (hexadecimal) to a base-10 number (decimal).


              "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

              P Offline
              P Offline
              Prakash Nadar
              wrote on last edited by
              #6

              I certaily agree with you? I was trying to be within the context of C/C++, Many newbies consider this as hexadecimal no. int x = 0xff; ;)


              I have lost more blood shaving than on the battlefield - Adolf Hitler

              D 1 Reply Last reply
              0
              • S styve

                Hi! Having problem by using sprintf. I have the hexadecimal 2B67, and will convert it to decimal by using sprintf. Can someone help me?? I know how to do vice verca.

                C Offline
                C Offline
                Cedric Moonen
                wrote on last edited by
                #7

                What you mean by hexadecimal 2b67 ??? From the machine, it's just the same than 11111 in base-10... The hexadeciaml is just the way YOU represent the number. But for the machine, it just sees 0's and 1's.

                1 Reply Last reply
                0
                • P Prakash Nadar

                  I certaily agree with you? I was trying to be within the context of C/C++, Many newbies consider this as hexadecimal no. int x = 0xff; ;)


                  I have lost more blood shaving than on the battlefield - Adolf Hitler

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  Mr.Prakash wrote: Many newbies consider this as hexadecimal no. int x = 0xff; While 0xff is indeed a hexadecimal number, the variable x is simply a spot in memory.


                  "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

                  1 Reply Last reply
                  0
                  • S styve

                    Hi! Having problem by using sprintf. I have the hexadecimal 2B67, and will convert it to decimal by using sprintf. Can someone help me?? I know how to do vice verca.

                    E Offline
                    E Offline
                    erkanina
                    wrote on last edited by
                    #9

                    As I understand you are trying to get hexadecimal equivalent of numeric, as mentioned by others; all data in memory stayed in hexadecimal format, the issue is to display that in hexadecimal acsii char array, take a look below; DWORD dwTest; char a[20]; dwTest=0xAABBCCDD; sprintf(a,"%x",dwText); AfxMessageBox(a);

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups