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

  • Home
  • SEARCH
  • 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 8260927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:13:32+00:00 2026-06-08T03:13:32+00:00

Hi I am trying to use the custom Binary Integer division method: Source: http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=642

  • 0

Hi I am trying to use the custom Binary Integer division method:
Source: http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=642

public static void DivMod (Int128 dividend, Int128 divisor, out Int128 quotient, out  Int128 remainder)
{
// Determine the sign of the results and make the operands positive.
int remainderSign = 1;
int quotientSign = 1;
if (dividend < 0)
{
    dividend = -dividend;
    remainderSign = -1;
}
if (divisor < 0)
{
    divisor = -divisor;
    quotientSign = -1;
}
quotientSign *= remainderSign;

quotient = dividend;
remainder = 0;
for (int i = 0; i < 128; i++)
{
    // Left shift Remainder:Quotient by 1
    remainder <<= 1;
    if (quotient < 0)
        remainder._lo |= 1;
    quotient <<= 1;

    if (remainder >= divisor)
    {
        remainder -= divisor;
        quotient++;
    }
}

// Adjust sign of the results.
quotient *= quotientSign;
remainder *= remainderSign;
}
  • However I have 2 problems:

1) I would like to use it for 32 bit integers not Int128. so I assume that the Int128 should be replaced by int, and the (int i = 0; i < 128; i++) should be replaced by i < 32;. Correct?

2) remainder._lo |= 1 -> this line does not work at all in C#. I suppose it has to do with that custom 128bit int struct they use, and I have no idea what it is meant to do. Can somebody help me out with this one, and translate it so that it works with int32?

EDIT: just to clarify I know what the bitwise operators do, the problem part is this:
remainder._lo. I dont know what this property refers to, and not sure of the purpose of this line, and how it would be translated to an int32?

  • 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-06-08T03:13:34+00:00Added an answer on June 8, 2026 at 3:13 am
    1. To use it with 32 bit integer (System.Int32) you can replace Int128 with int and the 128 in the for loop with 32 – So this is correct.

    2. The _lo property is just the lower 64 bits of the 128 bits number. It is used because the biggest integer type in .NET is 64 bits (System.Int64) – So with 32 bits you can just omit the property:
      remainder |= 1;

    If you follow the link you gave in your question and go back a few pages you will find the actual implementation of the Int128 struct. It starts here.

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

Sidebar

Related Questions

I'm trying to use phantom.js custom buildpack on Heroku ( https://github.com/stomita/heroku-buildpack-phantomjs ) I followed
I'm trying to use custom attributes to implement authorization permissions to execute a method.
I'm trying to use a custom object's method to emit to a socket connection.
I'm trying to use custom meta boxes in wordpress. My goal at the moment
I'm trying to use custom check boxes within Fancybox. They are showing up but
I am trying to use a custom segue to perform a kind of zoom
I'm trying to use a custom validator with jQuery Validation plugin. However, I'm unsure
I'm trying to use a custom UITableViewCell, and I've placed it in the same
I'm trying to use a custom font with the text in my Widget. Since
I am trying to simply use a custom view helper that is located in

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.