Why Does rnd() Keep Changing?

My friend Tom found this, I thought it was worth re-sharing:

I can think of several ways of making things like /dev/random stop changing, mainly based on what my customers have done to machines.

Comments on this entry are closed.

  • Hah! That’s absolutely astounding!

    You’ve got to wonder what they thought rnd() was…

  • Clearly misunderstanding the differences between generating a RANDOM, and wanting a ROUND function.

    I don’t know if .NET supports a ROUND function, oh well.

  • I agree with you that it’s a funny thing…. But I don’t think it’s right to mock the poor person who doesn’t understand the differences between round and random. It’s obvious that the person doesn’t know what he/she is doing and at least they’re asking for legitimate help in a fairly well respected knowledge board. Everyone has to start at the level of a basic “user/developer” Maybe a posting/direct e-mail would rectify that?

  • Well actually, while i cant ascertain the exact function of the program, in some cases, using a rnd() function that doesn’t change is quite usefull. (as in has a fixed series of numbers)

    Just imagine when programming a 3D enviroment, using a rnd() value for the coordinates of trees for example. using a rnd() function (thats still random, but has a fixed order) you have a very effectient way of generating the same layout of trees every time you render the scene. I’m not sure how this works in ASP.NET, but in VB6.0 the rnd() function is predictable, and great for such things. If you really need to randomize, you could use something like randomize timer (so that every minute the sequence of numbers would change).

    It was one of the first things I learned about programming using random values: rnd() is NOT random, theres always some logic in it, because it is generated by a computer that cant just “by instinct of gut feeling” pick a number.

  • @MarcW

    It all depends on what you seed it with

  • Matt, I totally agree with that, you can seed rnd() so much that it gets to be as close to really random as is possible with a computer. I just wanted to point out that there are advantages to having a rnd() that is predictable

  • Um, if you need a predictable rnd() just write your own:

    int rnd() {
    return 1;

  • @Dijutal, I think it’s perfectly fine to give this person a little bit of a hard time since they could have just looked it up in the online function reference. In this era of Google & total searchability a simple search should have tipped them off.

  • System.Math library, method Round(decimal, int);

  • sorry, that was in reply to Steven Schwartz

%d bloggers like this: