PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, July 19, 2022

[FIXED] How can I multiply really big numbers c++

 July 19, 2022     c++, integer, multiplication     No comments   

Issue

I have the following code

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

When these are multiplied it gives me -1431223188 which is not the answer. How can I make it give me the correct answer?


Solution

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



Answered By - Shravan40
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing