Hi,

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?

Recommended Answers

All 4 Replies

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.

No problem. Glad to help.

Be a part of the DaniWeb community

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