Siebel eScript Language Reference > Siebel eScript Commands > The Math Object >

Math.random() Method

This function returns a pseudo-random number between 0 and 1.




A pseudo-random number between 0 and 1.


This function generates a pseudo-random number between 0 and 1. It takes no parameters. Where possible, it should be used in place of the Clib.rand() method. The Clib.rand() method is to be preferred only when it is necessary to use Clib.srand() to seed the Clib random number generator with a specific value.


This example generates a random string of characters within a range. The Math.random() function is used to set the range between lowercase a and z.

function Test_Click ()
   var str1 = "";
   var letter;
   var randomvalue;
   var upper = "z";
   var lower = "a";

   upper = upper.charCodeAt(0);
   lower = lower.charCodeAt(0);

   for (var x = 1; x < 26; x++)
      randomvalue = Math.round(((upper - (lower + 1)) *
         Math.random()) + lower);
      letter = String.fromCharCode(randomvalue);
      str1 = str1 + letter;


See Also

Clib.rand() Method
Clib.srand() Method

Siebel eScript Language Reference