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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:17:28+00:00 2026-05-20T00:17:28+00:00

I am trying to generate a random enough number quickly. Right Now I am

  • 0

I am trying to generate a random enough number quickly.

Right Now I am using the following:

uniqueID() ->   C = random:uniform(9999) ,   %%%DO SPEED TEST
    random:seed(C,random:uniform(99),random:uniform(99)),
    {_, {H, Min, S}}  = calendar:universal_time(),
    {A, B} = statistics(wall_clock),
    (A*B) +((H + C + Min) * S).

It takes too long compared to something like make_ref().

6> make_ref().
#Ref<0.0.0.74>

How can I take the unique ref and parse it to become an integer?

such as 00074

Thanks for the help.

  • 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-20T00:17:28+00:00Added an answer on May 20, 2026 at 12:17 am

    Are you really sure you want to use erlang:make_ref/0 for unique numbers? Refs are only unique for one launch of one erlang vm – they are repeatable, predictable, and make lousy unique identifiers if you plan to use them for anything other than tags in erlang messages to match up requests and replies.

    You could do it by formatting the ref as a string (erlang:ref_to_list/1) and then parsing that.

    However, I think the best idea would be to use crypto:rand_bytes/1 to get yourself an N byte binary of random bytes, or crypto:rand_uniform/2 if you need a random integer in some range. This method at least gives you some guarantees as to the quality of the random integers you produce (see the openssl rand_bytes documentation).

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

Sidebar

Related Questions

I'm trying to generate a random real number between 0 and 1, using the
I am having trouble using srand. i am trying to generate a random number
I'm trying to generate a bunch of random numbers using rand() % (range). Here's
I have a number of rectangles, and am trying to generate a random point
i am trying to generate random number for my mental math quiz game. But
I am trying to generate a random prime number of type BigInteger, that is
I am trying to generate a random number, but it should not be a
I am trying to generate a random number between two floats (the max is
I'm trying to generate a random number that's between 0 and 1. I keep
I am trying to generate random text using letter frequencies that I have obtained.

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.