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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:28:56+00:00 2026-06-14T00:28:56+00:00

It might be a weird question, but I havent found any binary division java

  • 0

It might be a weird question, but I havent found any binary division java implementation browsing the internet. I will use it for CRC16 coding, so converting to decimal is not a solution. I understand the method on paper, but I am a beginner and since it’s very important I wouldn’t want to make it wrong. The only thing I found is a CRC.java on the code.google.com which uses binary division, but even if I only use the division part of that (removing the other parts) I dont get the desirable value.

Anybody can show me a java implementation of it? I’d appreciate it very much! Thanks in advance

The code what I found:

public class CRC {
private String data, divisor;

public CRC(String d, String di) {
    this.data = d;
    this.divisor = di;
}
public String getRemainder(String data, String divisor) {
    int x = 1, z = divisor.length(), j = 0, i;
    String data2 = "", strOfZeros = "";
    int y = divisor.length() - 1;
    /* This is to get correct amount of zero's onto the end of the data */
    while (y > 0) {
        data += "0";
        y--;
    }
    // Main part of method, this is the long division of Binary numbers.
    needToExit: for (i = x, j = 1; i < z && z <= data.length(); i++, j++) {
        if (z == data.length() && data2.charAt(0) == '1') {
            strOfZeros = "";
            for (i = 1; i < divisor.length(); i++) {    
                if (data2.charAt(i) == divisor.charAt(i))
                    strOfZeros += '0';
                else
                    strOfZeros += '1';
            }
            data2 = strOfZeros;
            break needToExit;
        }

        if (data.charAt(i) == divisor.charAt(j))
            data2 += "0";
        else
            data2 += "1";

        if (i == divisor.length() - 1) {
            data2 += data.charAt(z);
            x++;
            z++;
            // i = x;
            j = 0;

            // when first bit is a 0
            while (data2.charAt(0) != '1' && i == divisor.length() - 1) {
                for (i = 1; i < divisor.length(); i++) {
                    if (data2.charAt(i) == '0')
                        strOfZeros += "0";
                    else
                        strOfZeros += "1";
                }
                strOfZeros += data.charAt(z);
                data2 = strOfZeros;
                strOfZeros = "";
                x++;
                z++;
                i = x;
            }
        }

    }
    return data2;
}
public String getDataPlusCRC(String data){
    String str = data.concat(getRemainder(this.data, this.divisor));
    return str;
}

}

The getRemainder() method gives me a bad result when I try to divide to numbers. And this part is not necessary, because it needs for the CRC.

while (y > 0) {
            data += "0";
            y--;
        }
  • 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-14T00:28:57+00:00Added an answer on June 14, 2026 at 12:28 am

    BigInteger can do base 2 division;

        BigInteger divisor = new BigInteger("10", 2);
        BigInteger dividend = new BigInteger("100", 2);
        BigInteger result = dividend.divide(divisor);
    
        System.out.println(result.toString(2));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might seem like a weird question, but bear with me. I'd like to
This might be a weird question, but I'll try anyway. I set up my
OK, I realize that question might seem weird, but I just noticed something that
Maybe my question might seem a bit weird, but I have an activity in
This question might sound weird, but how do I make a job fail? I
I feel this might be a weird/stupid question, but here goes... In the question
This might be a weird question but I'm trying to figure out why the
This might be a weird question, but I know what I'm looking for i
Okay, this might seem like a weird question, but bear with me. So I
Hey guys, this question might be a little weird worded but I was looking

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.