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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:51:58+00:00 2026-05-31T16:51:58+00:00

I created a test application that generates 10k random numbers in a range from

  • 0

I created a test application that generates 10k random numbers in a range from 0 to 250 000. Then I calculated MAX and min values and noticed that the MAX value is always around 32k…

Do you have any idea how to extend the possible range? I need a range with MAX value around 250 000!

  • 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-31T16:51:59+00:00Added an answer on May 31, 2026 at 4:51 pm

    This is according to the definition of rand(), see:

    http://cplusplus.com/reference/clibrary/cstdlib/rand/

    http://cplusplus.com/reference/clibrary/cstdlib/RAND_MAX/

    If you need larger random numbers, you can use an external library (for example http://www.boost.org/doc/libs/1_49_0/doc/html/boost_random.html) or calculate large random numbers out of multiple small random numbers by yourself.

    But pay attention to the distribution you want to get. If you just sum up the small random numbers, the result will not be equally distributed.

    If you just scale one small random number by a constant factor, there will be gaps between the possible values.

    Taking the product of random numbers also doesn’t work.

    A possible solution is the following:

    1) Take two random numbers a,b
    2) Calculate a*(RAND_MAX+1)+b
    

    So you get equally distributed random values up to (RAND_MAX+1)^2-1

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

Sidebar

Related Questions

I have a program that generates some standard SQL like SELECT * FROM TEST
I created an ASP.NET MVC 2.0 Application. It ran fine at first test and
I've created some MbUnit Test Fixtures that have SetUp methods marked with the SetUp
We have an application that generates simulated data for one of our services for
I created a simple test application to perform translation ( T ) and rotation
I have created a test table in MySQL and would like to insert 10
In a Test project in Visual Studio 2008 (Pro), I created a Test project,
In showing a colleague how to use SVN yesterday, we created a test folder
I created a simple test page on my website www.xaisoft.com and it had no
I created a simple test with SendKeys, and tried both SendWait and Send. Private

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.