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 245357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:04:55+00:00 2026-05-11T21:04:55+00:00

I have a big number (integer, unsigned) stored in 2 variables (as you can

  • 0

I have a big number (integer, unsigned) stored in 2 variables (as you can see, the high and low part of number):

unsigned long long int high;
unsigned long long int low;

I know how to add or subtract some other that-kind of variable.

But I need to divide that-kind of numbers. How to do it? I know, I can subtract N times, but, maybe, there are more better solutions. 😉

Language: C

  • 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-11T21:04:55+00:00Added an answer on May 11, 2026 at 9:04 pm

    Yes. It will involve shifts, and I don’t recommend doing that in C. This is one of those rare examples where assembler can still prove its value, easily making things run hundreds of times faster (And I don’t think I’m exaggerating this.)

    I don’t claim total correctness, but the following should get you going :

    (1) Initialize result to zero.

    (2) Shift divisor as many bits as possible to the left, without letting it become greater than the dividend.

    (3) Subtract shifted divisor from dividend and add one to result.

    (4) Now shift divisor to the right until once again, it is less than the remaining dividend, and for each right-shift, left-shift result by one bit. Go back to (3) unless stopping condition is satisfied. (Stopping condition must be something like “divisor has become zero”, but I’m not certain about that.)

    It really feels great to get back to some REAL programming problems 🙂

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

Sidebar

Related Questions

You have an ASCII string representing a 128-bit unsigned integer number n, i.e. 0
If have a big 'xsl:choose' chunk in which I need to set a number
I have a big, complex MATLAB program. Somewhere within that, the number 0 is
I have a very big no say 'x' (10^18) and a number 'z' say
I'm trying to convert a 128-bit unsigned integer stored as an array of 4
The problem is easy to explain: we have two big arrays (32 bit integer
I am using a big number (over 128 bits integer) in my code. I
Does emacs have support for big numbers that don't fit in integers? If it
so I have this HTML table with a bunch of big numbers in it
I have big system that make my system crash hard. When I boot up,

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.