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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to change float to char*

how to change float to char*

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
7 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.
  • A Offline
    A Offline
    Angel Kid
    wrote on last edited by
    #1

    HI,Guys I tried all methods I know,but it seems all the methods don't work?Could anyone help me? YES, I am here.

    A H J 3 Replies Last reply
    0
    • A Angel Kid

      HI,Guys I tried all methods I know,but it seems all the methods don't work?Could anyone help me? YES, I am here.

      A Offline
      A Offline
      AlexO
      wrote on last edited by
      #2

      float f =-89.567; char * a = (char*)f;

      A R 2 Replies Last reply
      0
      • A Angel Kid

        HI,Guys I tried all methods I know,but it seems all the methods don't work?Could anyone help me? YES, I am here.

        H Offline
        H Offline
        Harald Krause
        wrote on last edited by
        #3

        char buffer[100]; sprintf(buffer,"%f",floatvalue); bb |~ bb

        A 1 Reply Last reply
        0
        • A AlexO

          float f =-89.567; char * a = (char*)f;

          A Offline
          A Offline
          Angel Kid
          wrote on last edited by
          #4

          thank you very much YES, I am here.

          1 Reply Last reply
          0
          • H Harald Krause

            char buffer[100]; sprintf(buffer,"%f",floatvalue); bb |~ bb

            A Offline
            A Offline
            Angel Kid
            wrote on last edited by
            #5

            thank you.But it seems that must include the file stdio.h YES, I am here.

            1 Reply Last reply
            0
            • A Angel Kid

              HI,Guys I tried all methods I know,but it seems all the methods don't work?Could anyone help me? YES, I am here.

              J Offline
              J Offline
              John M Drescher
              wrote on last edited by
              #6

              When I look at the answers I see that both answers are completly different. The first casts the float to a char* so that you can look at the bits of how the processor encoded the float. I am not sure why you would want that. [EDIT] Also if you want that you should use BYTE or unsigned char instead. [/EDIT] The second returns a string that represents the float number. This is more likely what you want. Which one are you looking for? John

              1 Reply Last reply
              0
              • A AlexO

                float f =-89.567; char * a = (char*)f;

                R Offline
                R Offline
                Ryan Binns
                wrote on last edited by
                #7

                That won't work at all. Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
                Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

                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