Division with two Huge Integers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Azaz ul haq
    New Member
    • Dec 2007
    • 4

    Division with two Huge Integers

    How to Divide a Huge Integer?

    e.g.
    99999999999/221321321321321
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    The same way you divide any other integer, divide 1 variable by another and store the result in a third.

    May be you should be more specific.

    Comment

    • manontheedge
      New Member
      • Oct 2006
      • 175

      #3
      you can't divide those two as integers. The result is less than one, so it will return 0.

      If you want an actual decimal value, you have to use double or float and not integer variables

      Comment

      • gpraghuram
        Recognized Expert Top Contributor
        • Mar 2007
        • 1275

        #4
        Originally posted by Azaz ul haq
        How to Divide a Huge Integer?

        e.g.
        99999999999/221321321321321

        I think u shuld use unsigned long long variable type to store the values u are using.
        gcc supports this

        Raghuram

        Comment

        • dtimes6
          New Member
          • Oct 2006
          • 73

          #5
          This sounds that you integer is stored in another form, so one method is to implement an structure use operator overloading to handle the case. you should provide you own algorithm of divide. one stupid way is sub if leftexpr is larger then the rightexpr and add the result by one. Please take care for the case c/0. And Good luck!

          Comment

          Working...