Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 860139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:46:20+00:00 2026-05-15T08:46:20+00:00

Guys I’m working on class called LINT (large int) for learning purposes, and everything

  • 0

Guys I’m working on class called LINT (large int) for learning purposes, and everything went ok till know. I’m stuck on implementing operator/(const LINT&). The problem here is that in when I want to divide LINT by LINT I’m getting into recursive fnc invocation i.e:

//unfinished
LINT_rep LINT_rep::divide_(const LINT_rep& bottom)const
{
typedef LINT_rep::Iterator iter;
 iter topBeg = begin();
 iter topEnd = end();
 iter bottomBeg = bottom.begin();
 iter bottomEnd = bottom.end();
LINT_rep topTmp;//for storing smallest number (dividend) which can be used to divide by divisor
 while (topBeg != topEnd)
 {
  topTmp.insert_(*topBeg);//Number not large enough add another digit
 if (topTmp >= bottom)
 {//ok number >= we can divide 
     LINT_rep topShelf = topTmp / bottom;//HERE I'M RUNNING INTO TROUBLE
 }
 else
 {


 }
 ++topBeg;
 }
 return LINT_rep("-1");//DUMMY
}

What I’m trying to do is to implement this as if I would divide those numbers by hand, so for example having for a dividend 1589 and for divisor 27 I would go like so:

  1. check if first digit is >= divisor and if so divide
  2. if not add to the first digit another digit and check if a > b

At some point it will be bigger (in simplified scenario) and if so I have to divide but in this case I’m running into recursive call and I have no idea how to break it.
One note: as a tmp I have to use LINT instead of int for example because those numbers my not fit into int.
So generally what I’m asking for is there any other way to do division? Or maybe there is false logic in my thinking (quite possible).
Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T08:46:21+00:00Added an answer on May 15, 2026 at 8:46 am

    When doing your part (1) you can’t divide; you have to repeatedly subtract, or guess to subtract a multiple, just like when you do it by hand. You can ‘guess’ more effectively by setting upper and lower bounds for the multiple required and doing a binary-chop through the range.

    I’ve done a similar thing myself; it’s a handy exercise to practice operator overloading. I can supply a snippet of code if you like, although it uses arrays and half-baked exceptions so I hesitate to offer it up before the expert readers of this site.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Guys, what is function called after my class loaded, where i can call self
Guys if I have class like below: template<class T> class X { T** myData_;
guys. I'm working on some audio services on iOS. I trying to search any
Guys I've a EntityModel called mapsModel , which has an entity Type called 'BodyChartNew'
Guys back to being stuck with my sql layout on my tables, I just
guys. I see several cases like: class Derived:public Base{ public: Derived(...):Base(...){} } Is what
guys, I have a case that needs the child class needs to call its
guys! I am very interested with ext gwt. Do you know any darg and
guys, recursion with grouping is not working. I am using XSLT 1.0. I need
Guys, I can't seem to get the object serialization working correctly clientside for my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.