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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:29:07+00:00 2026-06-16T09:29:07+00:00

Objective : Create a hash map that takes 2 integer keys(pointers converted to integers

  • 0

Objective : Create a hash map that takes 2 integer keys(pointers converted to integers using unsigned int casting, and yes this works) and maps it to a single value.

Attempted Solution: So i already have a hash map that takes a single key and maps it to value successfully. I now extended it to taking two keys using a “pairing function”. So i take the two keys , pair them using the Cantor pairing function and then hash this combined key .

Bottleneck: So the problem with two keys is that the cantor pairing function does a multiplication which causes integer overflow and hence “does not” give me unique outputs, as it is supposed to do mathematically.

Question:

  1. I see that a lot of hashing functions do multiplications. Is integer overflow a normal thing in hashing or is this bad?
  2. Im also thinking of doing an append of one key on the other into a new 64 bit integer. like aaaaaaaabbbbbbbb and then pass it on to the hash map. But I fear that this might cause abnormal numbers like NaN to come up due to the floating point representation, which could be bad.
  3. Any better ideas are welcome.

Please let me know if some parts are unclear.

  • 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-16T09:29:09+00:00Added an answer on June 16, 2026 at 9:29 am
    1. Integer overflow is not that bad. True it can cause collisions, but its ok to have rare collisions for hashes meant for a hashmap.

    2. Perhaps a bad idea. It can cause too many collisions.

    3. If your inputs are N bits wide, then your output will have to be at least 2N bits wide. So to accommodate uint inputs, you need an output of ulong size. If input is higher than that it will cause overflow. If output is smaller than that then there will be collisions/duplicates.

    But true there aren’t many functions which fit inside 2N size. You could try

    a * uint.MaxValue + b
    

    Or this

    a >= b ? a * a + a + b : a + b * b
    

    both of which will be an unsigned long. These two are the most space efficient it can get.

    See Mapping two integers to one, in a unique and deterministic way additionally.

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

Sidebar

Related Questions

I need to create an Objective-C method that converts an int into a byte
My end objective is to create an applescript that intelligently inserts a bullet point
Objective: I want to create a web service that allows me to connect to
How to create a TCP socket using Objective-C, check if some TCP ports are
Im trying to create a iPhone Objective C login page using PHP/MySQL to authenticate.
Possible Duplicate: create multiple variables based on an int count Objective C Equivalent of
My objective is create an apache module that will provide RESTful services (i.e., we
The objective is to create a custom route so that /undead will go to
I am using objective c to create a struct holding a variable length array.
hey i'm able to create hash table in Objective-C which stores data in XML

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.