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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:29:48+00:00 2026-06-11T23:29:48+00:00

Is there a standard, cross platform number generator/algorithm/library that if seeded with the same

  • 0

Is there a standard, cross platform number generator/algorithm/library that if seeded with the same input (in my case a hash of some sort), always produces the same set of pseudo-random numbers?

Ideally, I’d like to be able to do this cross platform, in both Java and .Net on any target machine, and get the same consistent output (vaguely random integers).

If it’s not possible, I’ll roll my own (my randomness requirements are very low, basically being used to assign different colors to something based on it’s ID – I just want to always assign the same color to the same item, no matter what system I’m running on).

  • 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-11T23:29:50+00:00Added an answer on June 11, 2026 at 11:29 pm

    There is a very simple and well known RNG algorithm, “Multiply-with-Carry”, that could be easily implemented on all platforms that I know of. It has the properties that you are requesting; it is up to you to decide whether it’s randomness would be adequate.

    From Wikipedia:

    An example of a simple pseudo-random number generator is the Multiply-with-carry method invented by George Marsaglia. It is computationally fast and has good (albeit not cryptographically strong) randomness properties.

    And here is the dead-simple implementation in C#, which you will have no trouble adapting to other languages:

    static int m_w = 1337;      // Choose initialization value, must not be zero
    static int m_z = 123123;    // Choose initialization value, must not be zero
    
    int GetRandom() 
    {
        m_z = 36969 * (m_z & 65535) + (m_z >> 16);
        m_w = 18000 * (m_w & 65535) + (m_w >> 16);
        return (m_z << 16) + m_w;  /* 32-bit result */
    }
    

    The initial values of m_w and m_z is the seed.

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

Sidebar

Related Questions

Is there a cross-platform library function that would collapse a multiline string into a
Is there a standard Java library that handles common file operations such as moving/copying
Is there an elegant, cross-platform, industry standard way of implementing substr() in C? or
I would like to know if there is a cross-platform (Windows, Linux, BSD) library
Are there standard file names for Terms of Use and Privacy Policies? For some
Is there any standard way of debugging Javascript on a webpage that's being accessed
Is there a standard convention for the types of files that go in \Windows\
Is there a standard or common way in C++ to handle static strings that
Is there a standard way / C# library to convert a string into a
Are there any extensible interpreted programming languages written in standard, platform-independent C or C++?

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.