Possible Duplicate:
converting a string into a double
What is the optimal way to convert string to double ? am using sstream but I feel it is not that fast.. is there a faster wawy without using any external libraries or sth.
Possible Duplicate:
converting a string into a double
What is the optimal way to convert string to double ? am using sstream but I feel it is not that fast.. is there a faster wawy without using any external libraries or sth.
strtod()
will have less overhead than using sstream
.
#include <stdlib.h>
char * s = ...;
double d = strtod(s, 0);
you can use boost library lexical cast They also include performance test results on their documentation page boost lexical cast
cheers