C++/multiply big numbers
Thanks for your reply ! I know how to write a program to multiply using float, long, and double data type. I just don't know how to deal with these these big numbers.
I need to multiply signed and unsigned 5o digits numbers. The input has to be from .txt file(not from the key board). Here is an example:
Will you please help me how to multiply these numbers either using C/C++. I'm using MS visual C++ 6.0 Thanks, I would really appreciate !
John , Thank you for your question.
To multiply multidigit decimal numbers, you might use the algorithm we all learned in primary school to do manual multiplication. If you don't recall this method in detail, try a Web search.
If you have any problems while writing your program, feel free to ask.
John, There is no built-in datatype to represent large numbers. Therefore, C++ has no simple way to do it.
You have to treat this as you would any programming task: design the data layout and the processing necessary to compute the result.
In this case, I recommend that you treat the numbers as arrays of signed characters. Take the ordinary manual multiplication method and implement it on this data layout. For example, your algorithm will start with the least significant (rightmost) digit and multiply it by each digit in the other number, summing and computing carry as it goes.
Be careful to distinguish a character that contains the ISO/ASCII/Unicode representation of a digit (as a printing character), from a binary number representing the actual digit. For example, the digit 0 is 0 in binary, but is represented as 30 (hexadecimal) as a printing character.