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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:44:26+00:00 2026-06-02T16:44:26+00:00

A BigInteter is too big to be converted into an integer. But I have

  • 0

A BigInteter is too big to be converted into an integer. But I have to store objects with an id (SHA 512) in a HashMap and need a hash function without many collisions.

I tried this. however, I am not sure if there is no clustering somewhere.

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    Advertisement other = (Advertisement) obj;
    return this.getId().equals(other.getId());
}

@Override
public int hashCode() {
    return new BigInteger(getId(), 16).hashCode();
}

would be a cast to an integer (bi.intValue()) more efficient?

  • 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-02T16:44:28+00:00Added an answer on June 2, 2026 at 4:44 pm

    Don’t try to reinvent the wheel – simply use getId().hashCode():

    @Override
    public int hashCode() {
        return getId().hashCode();
    }
    

    String.hashCode() uses an efficient, high-quality hashing algorithm, so it’s the best choice. And it makes your code simpler, which is always a good thing.

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

Sidebar

Related Questions

I have to write a biginteger into a text file using the following statement.
I'm doing some large integer computing, and I need to raise a BigInteger to
Implement Biginteger Multiply use integer array to store a biginteger like 297897654 will be
I need to invert a BigInteger . Let's say i have BigInteger x; and
I have an equation that I need to write in BigInteger format. It needs
Does valueOf for BigInteger have any limitations ? I'm not sure but read somewhere,
I have long [] data and i need to convert it to ArrayList<BigInteger> Is
I have a BigInteger value, let's say it is 282 and is inside the
I want to use the BigInteger class from the System.Numerics but if i want
I have the following code at the head of a method: BigInteger foo =

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.