I need help in converting a number which is written in scientific notation into the int.

For example I have this number: 6.538e-5 and its format is string. Any suggestion how can I convert it to the integer?

use the functions atoi() which converts ASCII characters to int.

you can use string streams to do this but you will to be able to put that number into an int. An int only holds integer values. You will need to put it into a double or float data type.

#include <sstream> // you will need this to use stringstream

string number = "6.538e-5";
double value;
stringstream ss;
ss << numbers;
ss >> value;

thanks alot NathanOliver. My code is working right now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.