Jump to content
  • Advertisement
Sign in to follow this  
TEUTON

Hash Function Problem

This topic is 4519 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Why We Use Magic Numbers Like 31 In Hashing Functions?? Is there any special significance of this number. I thought we should avoid magic numbers as much as possible considering about portability.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by TEUTON
Why We Use Magic Numbers Like 31 In Hashing Functions??

Is there any special significance of this number.

I thought we should avoid magic numbers as much as possible considering about portability.


The so called "Magic Numbers" are just Prime Numbers that allow you to guarantee that you will have a unique hash for a larger amount of numbers to prevent collisions where as if you used another number that was non-prime, you would have more collisions.

I had an example, but it was wrong due to how I miscounted, so look at this link for applications of Prime Numbers in Hash Functions [wink]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!