Numbers + Random

So.... i have seen quite a few programs on here that do a wide variety of things in the last month or so i have been playing with the arduino and scavenging all the information i can get about kewl projects i may be interesting in putting together.

One thing i can't see the difference in is people who do the number add method instead of just typing the number.

for example, whats the difference in...

random (255);


random ((120) + 135);

Does it really matter? i have seen quite a few people who do this addition method but normally it seems it would be easier just to put what you want in there and continue on......i dunno maybe i'm just thick.

:-/ i'm confused.....

When the random function actually get invoked, the result is the same value being passed in.

The reason for not adding the numbers together in advance generally comes form the separate numbers having meaning to the author, but the resulting added number looses that significance.

For example, if I'm writing code to simulate the roll of dice, I'd be inclined to write random(6 + 6); than to write random(12); because it's more obvious (to me) that 6 has significance whereas 12 requires a moment's thought.

Bad example.
To simulate the roll of the dice you’d have to write random(6) + random(6).

(Sorry, couldn’t resist…)

Of course, you're right. It was the only thing that I could think of right away. There are cases, though, where adding the numbers together obscures the meaning, and letting the Arduino add them takes very little time.

Ok. So pretty much it's for no programming significance other than to make the code easier to read if the numbers have alternate meaning to the viewer.