-
February 14th, 2011, 06:49 PM
#1
Quick and dirty string scan to float
No point in re-inventing the wheel.
Given "1.234" as a string, how do you get a float?
-
February 14th, 2011, 06:56 PM
#2
Re: Quick and dirty string scan to float
-
February 14th, 2011, 07:08 PM
#3
Re: Quick and dirty string scan to float
Thanks, that led in the right direction, needed _wtof.
-
February 15th, 2011, 10:34 AM
#4
Re: Quick and dirty string scan to float
-
February 15th, 2011, 12:49 PM
#5
Re: Quick and dirty string scan to float
Originally Posted by Marc G
Or the C++0x stof().
Is there documentation on this somewhere? First I've heard of it.
-
February 15th, 2011, 01:33 PM
#6
Re: Quick and dirty string scan to float
-
February 17th, 2011, 09:21 AM
#7
Re: Quick and dirty string scan to float
Originally Posted by Lindley
Is there documentation on this somewhere? First I've heard of it.
It's in the draft standard document which you can freely download. (http://www.open-std.org/JTC1/SC22/WG21/docs/papers/) Here is a quote:
Code:
// 21.5: numeric conversions
int stoi(const string& str, size_t *idx = 0, int base = 10);
long stol(const string& str, size_t *idx = 0, int base = 10);
unsigned long stoul(const string& str, size_t *idx = 0, int base = 10);
long long stoll(const string& str, size_t *idx = 0, int base = 10);
unsigned long long stoull(const string& str, size_t *idx = 0, int base = 10);
float stof(const string& str, size_t *idx = 0);
double stod(const string& str, size_t *idx = 0);
long double stold(const string& str, size_t *idx = 0);
string to_string(int val);
string to_string(unsigned val);
string to_string(long val);
string to_string(unsigned long val);
string to_string(long long val);
string to_string(unsigned long long val);
string to_string(float val);
string to_string(double val);
string to_string(long double val);
+ wide versions of all the above.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|