How can we convert a string to int for very large integer values?

前端 未结 4 1022
隐瞒了意图╮
隐瞒了意图╮ 2021-01-12 14:11

I have used the function atoi to convert character strings to int and it\'s working fine but when I gave

num = atoi (argv[1]) ;

/         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-12 14:48

    If you want to handle seriously very large numbers then you need a library like GMP.

    GMP stands for GNU Multiple Precision and it is a BigNum library, which means it has code to handle integers bigger than 32 bits or 64 bits. It can handle as many bits as you have RAM.

    To convert a string into an integer you would use the GMP function mpz_set_str()

提交回复
热议问题