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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:27:04+00:00 2026-05-19T23:27:04+00:00

I am trying to solve a problem that involves basically implementing a logical AND

  • 0

I am trying to solve a problem that involves basically implementing a logical AND between the input parameter.

The complexity of the problem involves the size of the input parameters. To give a high level overview, I am trying to implement the logic similar to

100 & 100 == 100
001 & 010 == 0
001 & 100 == 0
.....

The complexity is that some of the input parameters can be 400 bits long. Its not a true binary number representation. It’s more of a positional representation. The same input can be represented as

100 = x1; (or) x100
011 = x2,3; (or) x011
001.......11 = x3,......450,451;

So basically “x” is just a prefix with the value for it. This is an ACL system designed a long time ago and I am trying to implement a Java version for it.

I couldn’t find a data type in Java that could be used to represent a binary representation that is as huge as having 400 bits. I can also use the decimal representation [ie., x2,3] and solve it too, but I couldn’t think of way other than looping through the entire number range and comparing it with the other input parameter. Both input parameters could be normalized to the same representation format [ie., binary or decimal].

Any suggestions (or) help on how I can solve this problem?

  • 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-19T23:27:04+00:00Added an answer on May 19, 2026 at 11:27 pm

    You could use a BitSet. It has support for bitwise and-operations and should handle 400 bits quite well.

    Here is an example:

    BitSet bs1 = new BitSet();
    bs1.set(2);
    bs1.set(5);
    bs1.set(7);
    bs1.set(8);
    
    BitSet bs2 = new BitSet();
    bs2.set(2);
    bs2.set(7);
    bs2.set(9);
    
    bs1.and(bs2);
    
    // Prints {2, 7}
    System.out.println(bs1);
    

    To parse a x110101 string, you could do something like

    String acl = "x110101";
    
    BitSet bs1 = new BitSet();
    for (int i = 1; i < acl.length(); i++)
        if (acl.charAt(i) == '1')
            bs1.set(i);
    

    If you still don’t like that approach, you could use a Set<Integer> containing the indecies of the ones. To figure out the “and” between two such sets, you simply do set1.retainAll(set2).

    Here is an example:

    Set<Integer> bs1 = new HashSet<Integer>();
    bs1.add(2);
    bs1.add(5);
    bs1.add(7);
    bs1.add(8);
    
    Set<Integer> bs2 = new HashSet<Integer>();
    bs2.add(2);
    bs2.add(7);
    bs2.add(9);
    
    bs1.retainAll(bs2);
    
    // Prints [2, 7]
    System.out.println(bs1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to solve a problem that should be simple to solve. I'm trying
So I'm trying to solve this problem that asks to look for palindromes in
Trying to solve this problem: I have the following set of divs that when
I'm trying to solve this problem where I have a unique array of values
In the Grails 1.2.5 project that I am trying to troubleshoot, we use the
update SOLVED - the problem is not with my code. there is a design
Possible Duplicate: Jquery IE6 hover problems, keeps loading background image. Hello I am trying
I have recently started playing with databases, trying to teach myself using examples. I
So, we are trying to execute the following code. The two if statements are
Guys I am new to Entity Framework and I'm having a bt of a

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.