I have to multiply two big numbers - saved as string - any hint how to do that?
Asked
Active
Viewed 902 times
1
-
How big are the numbers, and what language? `bc` can already do it at your command line if you have a unix-like machine. – Carl Norum Feb 11 '11 at 22:03
-
2What computer language are you using? – typo.pl Feb 11 '11 at 22:04
-
what language are you using? Most languages have libraries for that - for instance in java you could use BigInteger or BigDecimal – Zevan Feb 11 '11 at 22:04
-
what language both .net and Java have big number classes – Iain Feb 11 '11 at 22:05
-
Note that homework questions are fine, but you/we just need to tag the question appropriately. – Phrogz Feb 11 '11 at 22:05
-
1See http://stackoverflow.com/questions/1218149/arbitrary-precision-arithmetic-explanation/1218185#1218185 – paxdiablo Feb 11 '11 at 22:06
2 Answers
5
Think back to grade school, and how you would solve the problem long-hand.

Mark Ransom
- 299,747
- 42
- 398
- 622
1
Depends on the language and how large the numbers are. For example in C, you can convert string to int with atoi and then multiply if the product will fit in 32bit int. If number is too large for 32bit you'll probably have to use third-party BigInt library. Some languages (python, haskell) have built-in support for bigint, so you can multiply numbers of any size.

kefeizhou
- 6,234
- 10
- 42
- 55