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 convert WCHAR* to FLOAT64?

How to convert WCHAR* to FLOAT64?

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

    I need help learning how to convert a WCHAR* which points to a string such as L"118.000" to a FLOAT64. I am trying to do it like this: if(IsValidComFreq(freq)) { wchar_t** end = NULL; m_Com3Stby = wcstol(freq, end, 10); } ** Where: FLOAT64 m_Com3Stby; // a double WCHAR *freq = L"118.000"; // for example But I am guessing this is wrong. What is the best way to do this? Thanks.

    M L K J 4 Replies Last reply
    0
    • S Stick

      I need help learning how to convert a WCHAR* which points to a string such as L"118.000" to a FLOAT64. I am trying to do it like this: if(IsValidComFreq(freq)) { wchar_t** end = NULL; m_Com3Stby = wcstol(freq, end, 10); } ** Where: FLOAT64 m_Com3Stby; // a double WCHAR *freq = L"118.000"; // for example But I am guessing this is wrong. What is the best way to do this? Thanks.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      How about _wtof() instead of wcstol()? Mark

      1 Reply Last reply
      0
      • S Stick

        I need help learning how to convert a WCHAR* which points to a string such as L"118.000" to a FLOAT64. I am trying to do it like this: if(IsValidComFreq(freq)) { wchar_t** end = NULL; m_Com3Stby = wcstol(freq, end, 10); } ** Where: FLOAT64 m_Com3Stby; // a double WCHAR *freq = L"118.000"; // for example But I am guessing this is wrong. What is the best way to do this? Thanks.

        L Offline
        L Offline
        led mike
        wrote on last edited by
        #3

        They hide that information in the documentation[^]

        led mike

        1 Reply Last reply
        0
        • S Stick

          I need help learning how to convert a WCHAR* which points to a string such as L"118.000" to a FLOAT64. I am trying to do it like this: if(IsValidComFreq(freq)) { wchar_t** end = NULL; m_Com3Stby = wcstol(freq, end, 10); } ** Where: FLOAT64 m_Com3Stby; // a double WCHAR *freq = L"118.000"; // for example But I am guessing this is wrong. What is the best way to do this? Thanks.

          J Offline
          J Offline
          James R Twine
          wrote on last edited by
          #4

          I do not think that FLOAT64 is a proper type...  Are you sure that is what you need to convert to, and not int64 or double?    Peace!

          -=- James


          If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
          Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
          DeleteFXPFiles & CheckFavorites (Please rate this post!)

          Z S 2 Replies Last reply
          0
          • S Stick

            I need help learning how to convert a WCHAR* which points to a string such as L"118.000" to a FLOAT64. I am trying to do it like this: if(IsValidComFreq(freq)) { wchar_t** end = NULL; m_Com3Stby = wcstol(freq, end, 10); } ** Where: FLOAT64 m_Com3Stby; // a double WCHAR *freq = L"118.000"; // for example But I am guessing this is wrong. What is the best way to do this? Thanks.

            K Offline
            K Offline
            krmed
            wrote on last edited by
            #5

            You should use wcstod instead - it returns a double. Your wcstol only returns a long, so it will just return 118 (even if your input was 118.243). Hope that helps.

            Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

            S 1 Reply Last reply
            0
            • J James R Twine

              I do not think that FLOAT64 is a proper type...  Are you sure that is what you need to convert to, and not int64 or double?    Peace!

              -=- James


              If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
              Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
              DeleteFXPFiles & CheckFavorites (Please rate this post!)

              Z Offline
              Z Offline
              Zac Howland
              wrote on last edited by
              #6

              It could be a typedef or define somewhere ... Most likely for double.

              If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

              1 Reply Last reply
              0
              • K krmed

                You should use wcstod instead - it returns a double. Your wcstol only returns a long, so it will just return 118 (even if your input was 118.243). Hope that helps.

                Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

                S Offline
                S Offline
                Stick
                wrote on last edited by
                #7

                Thanks, that was the ticket. Stupid me forgot the diff between a long and a double.

                1 Reply Last reply
                0
                • J James R Twine

                  I do not think that FLOAT64 is a proper type...  Are you sure that is what you need to convert to, and not int64 or double?    Peace!

                  -=- James


                  If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                  Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                  DeleteFXPFiles & CheckFavorites (Please rate this post!)

                  S Offline
                  S Offline
                  Stick
                  wrote on last edited by
                  #8

                  FLOAT64 is an MS typedef that is commonly used by those of us that program for Windows.

                  J R 2 Replies Last reply
                  0
                  • S Stick

                    FLOAT64 is an MS typedef that is commonly used by those of us that program for Windows.

                    J Offline
                    J Offline
                    James R Twine
                    wrote on last edited by
                    #9

                    Hmmm... Not viewed my profile, eh?    I have been programming on Windows ever since the 3.0 days and I have never seen FLOAT64.  I would bet that the typedef is not found in a common (common as is commonly available) MS SDK file.  In fact, the only pseudo-Windows-specific place I can find it is in MSIL, and this IS the VC++ board... :)    Anyway... A 64-bit floating point variable is a double, and that is likely the real type behind the typedef.  In that case, something like ::_wcstod(...) should do the trick.    Peace! -- modified at 8:24 Wednesday 13th December, 2006

                    -=- James


                    If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                    Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                    DeleteFXPFiles & CheckFavorites (Please rate this post!)

                    S 1 Reply Last reply
                    0
                    • J James R Twine

                      Hmmm... Not viewed my profile, eh?    I have been programming on Windows ever since the 3.0 days and I have never seen FLOAT64.  I would bet that the typedef is not found in a common (common as is commonly available) MS SDK file.  In fact, the only pseudo-Windows-specific place I can find it is in MSIL, and this IS the VC++ board... :)    Anyway... A 64-bit floating point variable is a double, and that is likely the real type behind the typedef.  In that case, something like ::_wcstod(...) should do the trick.    Peace! -- modified at 8:24 Wednesday 13th December, 2006

                      -=- James


                      If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                      Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                      DeleteFXPFiles & CheckFavorites (Please rate this post!)

                      S Offline
                      S Offline
                      Stick
                      wrote on last edited by
                      #10

                      Just goes to show that: a) The length of time you have attempted to do something is not necessarily directly proportional to the amount you know about something. and b) it does not matter if you think something is "proper" or not, but it certainly does tell us (along with your reference to your profile) about you. Peace back at ya.

                      J 1 Reply Last reply
                      0
                      • S Stick

                        FLOAT64 is an MS typedef that is commonly used by those of us that program for Windows.

                        R Offline
                        R Offline
                        Rick York
                        wrote on last edited by
                        #11

                        FLOAT64 is not a MS typedef. It does not exist in VC++ v6.0 or v7.1 nor is it listed on any page in MSDN that I could find. There is a float64 defined but VC++ is case sensitive and this is the VC++ forum.

                        S J 2 Replies Last reply
                        0
                        • R Rick York

                          FLOAT64 is not a MS typedef. It does not exist in VC++ v6.0 or v7.1 nor is it listed on any page in MSDN that I could find. There is a float64 defined but VC++ is case sensitive and this is the VC++ forum.

                          S Offline
                          S Offline
                          Stick
                          wrote on last edited by
                          #12

                          It is a Microsoft typedef, just not one you have seen, which is EXACTLY why I told you it IS a Microsoft typedef, and part of a very long MS header that you just don't happen to have on your machine. Not everything used by MS is in the docs or on the web (or in your header files).

                          1 Reply Last reply
                          0
                          • S Stick

                            Just goes to show that: a) The length of time you have attempted to do something is not necessarily directly proportional to the amount you know about something. and b) it does not matter if you think something is "proper" or not, but it certainly does tell us (along with your reference to your profile) about you. Peace back at ya.

                            J Offline
                            J Offline
                            James R Twine
                            wrote on last edited by
                            #13

                            A) and in some cases, it is... And I at least know that a double is 8 bytes wide, thus is a 64-bit floating point type and not a integer value.  And as you have demonstrated, your point also applies the other way.    You still have not identified where FLOAT64 is a MS typedef that is commonly used.  I also did not notice it in my driver SDK and IFS SDK files.  And even if it was in the IFS SDK, the Platform SDK is commonly available, but the IFS SDK is not (or at least was not), so common would not apply.    B) When you have a wide and deep coverage of a certain area, your thoughts on what is proper or not do matter.  Note that they do not have to matter to you.    Peace!

                            -=- James


                            If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                            Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                            DeleteFXPFiles & CheckFavorites (Please rate this post!)

                            1 Reply Last reply
                            0
                            • R Rick York

                              FLOAT64 is not a MS typedef. It does not exist in VC++ v6.0 or v7.1 nor is it listed on any page in MSDN that I could find. There is a float64 defined but VC++ is case sensitive and this is the VC++ forum.

                              J Offline
                              J Offline
                              James R Twine
                              wrote on last edited by
                              #14

                              Yeah, I am fairly confident that MSDN and Google combined cover the area of "common" quite well.    Peace!

                              -=- James


                              If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                              Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                              DeleteFXPFiles & CheckFavorites (Please rate this post!)

                              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