About 9,550,000 results
Open links in new tab
  1. How do I get a specific range of numbers from rand ()?

    Jul 30, 2009 · Here is my answer there, which contains the definition for my int utils_rand(int min, int max) func, which returns a random number using rand() which is in the specific range from …

  2. How does rand() work in C? - Stack Overflow

    Oct 28, 2015 · The rand() function takes the 'seed' to produce the next random output value, then generates a new 'seed' from the old 'seed' then returns the 'random' output value

  3. c - How does srand relate to rand function? - Stack Overflow

    I assume it would look something like rand (srand (time (null)); It's like initializing a variable without using it to me. srand is being initialized, but I don't see it being used. Does rand …

  4. c++ - How does modulus and rand () work? - Stack Overflow

    Oct 24, 2013 · A second lesson is that this shows another way in which <random> is easier to use than rand() and manually computing your own distributions. The built-in …

  5. Generate a value between 0.0 and 1.0 using rand () - Stack Overflow

    The OP's reasoning for trying it was wrong, but had this been necessary, the UB could've been avoided by adding 1.0 instead of 1, which would coerce RAND_MAX to double type and so …

  6. Why do I always get the same sequence of random numbers with …

    22 To quote from man rand : The srand () function sets its argument as the seed for a new sequence of pseudo-random integers to be returned by rand (). These sequences are …

  7. c - What does `rand () % 2` mean? - Stack Overflow

    Jun 12, 2023 · The rand() % 2 is a way of generating a pseudo-random number that's either 0 or 1. The rand() function generates a pseudo-random integer. When you take the modulus of that …

  8. c - Rand Implementation - Stack Overflow

    Jan 22, 2011 · I would like to go through how rand() and srand() functions are implemented and would like to tweak the code to modify it to my requirements. Where can i find the source code …

  9. How do I generate a random integer in C#? - Stack Overflow

    { Random rand = new Random((int)DateTime.Now.Ticks); return rand.Next(min, max); } if you are looking for random number generator for normal distribution, you might use a Box-Muller …

  10. Getting random numbers in Java - Stack Overflow

    I would like to get a random value between 1 to 50 in Java. How may I do that with the help of Math.random();? How do I bound the values that Math.random() returns?