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. double to ascii conversion

double to ascii conversion

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
7 Posts 6 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
    shaans
    wrote on last edited by
    #1

    pls help me in my trouble.i want to convert double value to ascii.can u give code for that?if it is not possible how can i do it? shan

    T P A D 4 Replies Last reply
    0
    • S shaans

      pls help me in my trouble.i want to convert double value to ascii.can u give code for that?if it is not possible how can i do it? shan

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      double d = 5.4E3;
      char str[50];
      sprintf(str, "%f", d);

      cheers,


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      1 Reply Last reply
      0
      • S shaans

        pls help me in my trouble.i want to convert double value to ascii.can u give code for that?if it is not possible how can i do it? shan

        P Offline
        P Offline
        peiman
        wrote on last edited by
        #3

        MFC: double dblValue = sqrt(2); CString csText; csText.Format("%f",dblValue); C: char Buffer[256]; double dblValue = sqrt(2); sprintf(Buffer,"%f",dblValue); :~

        1 Reply Last reply
        0
        • S shaans

          pls help me in my trouble.i want to convert double value to ascii.can u give code for that?if it is not possible how can i do it? shan

          A Offline
          A Offline
          achainard
          wrote on last edited by
          #4

          %g or %f in sprintf: %f => double Signed value having the form [ – ]dddd.dddd, where dddd is one or more decimal digits. The number of digits before the decimal point depends on the magnitude of the number, and the number of digits after the decimal point depends on the requested precision. %g => double Signed value printed in f or e format, whichever is more compact for the given value and precision. The e format is used only when the exponent of the value is less than –4 or greater than or equal to the precision argument. Trailing zeros are truncated, and the decimal point appears only if one or more digits follow it. Extract from MSDN doc. ...

          1 Reply Last reply
          0
          • S shaans

            pls help me in my trouble.i want to convert double value to ascii.can u give code for that?if it is not possible how can i do it? shan

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

            shaans wrote: i want to convert double value to ascii. This makes no sense. With the exception of Unicode, all of the characters, numbers, and symbols you can type are ASCII. There is no such thing as converting from any of those to ASCII. Please explain further what it is that you are attempting to do.


            "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

            A 1 Reply Last reply
            0
            • D David Crow

              shaans wrote: i want to convert double value to ascii. This makes no sense. With the exception of Unicode, all of the characters, numbers, and symbols you can type are ASCII. There is no such thing as converting from any of those to ASCII. Please explain further what it is that you are attempting to do.


              "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

              A Offline
              A Offline
              Anonymous
              wrote on last edited by
              #6

              CString sr=m_edit6.Left(3); //ch=sr.GetAt(0); char *t; double dt=::strtod(sr,&t); CString str1; str1.Format("%g",dt); MessageBox(str1); this str1 contains a double value.i want to convert this double value into its ASCII value.plz help mw with this.

              D 1 Reply Last reply
              0
              • A Anonymous

                CString sr=m_edit6.Left(3); //ch=sr.GetAt(0); char *t; double dt=::strtod(sr,&t); CString str1; str1.Format("%g",dt); MessageBox(str1); this str1 contains a double value.i want to convert this double value into its ASCII value.plz help mw with this.

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

                Why the extra step? sr --> dt --> str1 :confused: How about:

                str1.Format("%g", (LPCSTR) m_edit6.Left(3));

                If you need the intermediate step, why not use atof() instead of strtod()? Anonymous wrote: this str1 contains a double value.i want to convert this double value into its ASCII value. Let me see if I have this right. If str1 contains the value 123.45, what exactly is it that you want it converted to? The ASCII value of 1 is 49, 2 is 50, etc. The ASCII value of the decimal is 46. How are you wanting to store these values?


                "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

                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