How can I multiply really big numbers c++

前端 未结 9 1667
梦谈多话
梦谈多话 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:52

    First, you have to make your value long longs Second, you would want to add a (long long) in front of the multiplication. This is because when you have (ab) it returns an int therefore if you want it to return a long long you would want (long long)(ab).

提交回复
热议问题