-2

May be I am already reinventing the wheel.

Normally in C, if we have a=34 and b=5 we get a/b=6. But I need the same thing for 100 digit numbers. I wrote a class with name Int. which does a+b and a-b and a*b. (a,b,c are type Int)

I overloaded the operators << , >>, which will return number divided or multiplied with 10.

What is the best algorithm for division? (assuming I store numbers as strings with base 10".

Thanks.

Anil
  • 578
  • 4
  • 12
  • 3
    I'm not so sure introducing those semantics on the bit shift operators is such a good idea. – chris Feb 14 '13 at 06:19
  • Funny, I've implemented a bignum class myself a while ago and i did exact same thing, used << and >> to multiply and divide by 10^n. – Spook Feb 14 '13 at 06:21

2 Answers2

2

Perhaps you should consult https://en.wikipedia.org/wiki/Division_%28digital%29, specifically the section on large integer methods.

Andrew Mao
  • 35,740
  • 23
  • 143
  • 224
1

You're reinventing the wheel. See: http://gmplib.org/

WaywiserTundish
  • 122
  • 1
  • 3