How can I multiply really big numbers c++

前端 未结 9 1741
梦谈多话
梦谈多话 2021-01-18 10:09

I have the following code

      int i, a, z;
i = 2343243443;
a = 5464354324324324;
z = i * a;
cout << z << endl;

When these are

9条回答
  •  耶瑟儿~
    2021-01-18 10:53

    As Jarod42 suggested is perfectly okay, but i am not sure whether overflow will take place or not ?

    Try to store each and every digit of number in an array and after that multiply. You will definitely get the correct answer.

    For more detail how to multiply using array follow this post http://discuss.codechef.com/questions/7349/computing-factorials-of-a-huge-number-in-cc-a-tutorial

提交回复
热议问题