How to convert WCHAR* to FLOAT64?
-
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.
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
-
I do not think that
FLOAT64
is a proper type... Are you sure that is what you need to convert to, and notint64
ordouble
? 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!)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
-
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
-
I do not think that
FLOAT64
is a proper type... Are you sure that is what you need to convert to, and notint64
ordouble
? 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!) -
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!) -
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!)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.
-
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.
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).
-
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.
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!) -
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.
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!)