Why Does rnd() Keep Changing?

by Bob Plankers on October 6, 2008 · 10 comments

in Funny,System Administration

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.


Matt Simmons October 6, 2008 at 12:28 PM

Hah! That’s absolutely astounding!

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

Steven Schwartz October 6, 2008 at 2:07 PM

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.

Dijutal_Phreak October 6, 2008 at 9:11 PM

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?

MarcW October 7, 2008 at 4:15 AM

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.

Matt Simmons October 7, 2008 at 2:12 PM


It all depends on what you seed it with

MarcW October 8, 2008 at 1:21 AM

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

Bob Plankers October 8, 2008 at 1:29 AM

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

int rnd() {
return 1;

Bob Plankers October 8, 2008 at 1:35 AM

@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.

Lawrence December 21, 2010 at 7:36 AM

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

Lawrence December 21, 2010 at 7:37 AM

sorry, that was in reply to Steven Schwartz

Comments on this entry are closed.

Previous post:

Next post: