The documentation says it all:“Generates a random number between 0 and 1, inclusive.”
Inclusive means you’ll have a hard time getting a random integer out of it.
@Integer(@Random*n) gives a random integer from 0 to n-1, but sometimes you’ll get a “n” (much less often than any other value of course).
So you can’t count it as one of the random target numbers, but if you did not consider this 0 case in your formula, sometimes something weird will happen.
Oh yes, you can also use @Round instead of @Integer to get an integer from 0 to n, but then 0’s and n’s occur twice less than other values – not really what you expect from a “random” function.
Every other random number generator implementation I know of (including LS) returns a number from 0 to 1 exclusive. There’s no wonder why.
Lotus choosed to do it another way at the time @Random was added in early Notes versions.
AFAIK the most correct way to generate a random integer in R6 is to use:
@DoWhile(r=@Integer(@Random*n);r=n)
In R4/R5, you can resort to @Integer(@Random-@Power(10;-15)), which only gets it minorly wrong.
Lastly, I think IBM could and should correct this bad behaviour.
Making @Random generate a random number between 0 and 1, EXCLUSIVE, won’t break anything: I can’t imagine any application relying on @Random returning one discreet value, be it 1.
While using @Random like you’d use a random function in any programming language and getting hit by the “inclusive 1” corner case sounds MUCH more likely to happen.
Comments?