how to operate on large value taken in form of string

how to opearate on large number taken in form of string ie how to convert it back into number?
Last edited on
You can use a stringstream to convert back to an integer, but that doesn't work if the number is too big to fit. What are you trying to do in specific?
@Zhuge i am taking a number of order 10^15 in form of string and want it back in form of inetger can you please tell me how to use stringstream??
Firstly you would need to use a long long int (log(2, 10^15) ~=~50). secondly a quick and simple Google will help you with stringstreams. Post some code if you get stuck.
closed account (iAk3T05o)
I think it's something like this:
1
2
3
4
5
6
                             
#include <sstream>      
long int hmm;          
std::string blah = "10 ^ 15";                                          
std::stringstream(blah) >> hmm;                              
std::cout << hmm;          

I am not sure that'll work because i'm usually the one that inputs the 10^15 using cin. So check google
Topic archived. No new replies allowed.