Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
"3.1e-05" this is the string and I want to convert this string into numeric output ll be 1.00003

Any suggestion will be greatly appreciated.
Posted
Updated 29-Mar-11 5:57am
v2

What's wrong with using sscanf?

Cheers!
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 29-Mar-11 12:31pm    
I guess, nothing's wrong... with my vote of 5.
--SA
Manfred Rudolf Bihy 29-Mar-11 14:09pm    
Thanks SA!
Is it a string or char*? Assuming the latter,

C++
#include <stdlib.h>
const char* str = "3.1e-05";
//...
double value = atof(str);


—SA
 
Share this answer
 
v3
Comments
Olivier Levrey 29-Mar-11 12:29pm    
My 5. I just fixed the tags...
Sergey Alexandrovich Kryukov 29-Mar-11 12:31pm    
Thank you for the fix and the vote.
--SA
Manfred Rudolf Bihy 29-Mar-11 14:09pm    
How could I forget the float pendant to atoi. My 5!
Sergey Alexandrovich Kryukov 29-Mar-11 15:06pm    
Thank you, Manfred.
--SA
C#
int _tmain(int argc, _TCHAR* argv[])
{
  TCHAR*  e;
  _tprintf(__T("%.5lf"),_tcstod(1<argc?argv[1]:__T("3.1e-05"),&e));
  _gettch();
  return 0;
}

Thats easy, isnt?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900