Message-ID: <100397793.26169.1576110859197.JavaMail.root@confluence> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_26168_905518977.1576110859196" ------=_Part_26168_905518977.1576110859196 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Generating a Random Number

# Overview

random

• Return:  Returns a random number between 0.0 (inc= lusive) and 1.0 (exclusive) (ex. 0.738).
• Arguments: None
• Usage: random()
• Example Usage: When you need to generate a random= number.
• For example, to generate a number between 5 (inclusive) and 23 (exclusi= ve), you can use (random()*(23 - 5)) + 5.  This will be something like= 12.43334.
• You can convert that to a whole number by using int((random()*(23 - 5))= + 5).  You can also reference questions instead of directly typing nu= mbers.
• Ex. int(random()*(#form/high_num - #form/low_num) + #form/low_num). &nb= sp;
• The output varies between low_num (inclusive) and high_num (exclusive)<= /li>

You can generate either a random d= ecimal number (ex. 8.9) or a random integer (ex. 22) using the random() fun= ction.  Set the calculate expression of your question to the following= :

1. For a random decimal: start_num + (random() * (end_num - start_num)) Fo= r example, to generate random number between 10.3 and 30.9, you can use 10.= 3 + (random() * (30.9 - 10.3))
2. For a random integer: start_num + int(random() * (end_num - start_= num)) For example, to generate random number between 9 and 22, you can use = 9 + int(random() * (22 - 9))

You can also replace start_num and end_num with references to other ques= tions in your form (ex. #form/my_start_range_question).  Please make s= ure that they are required or have value so that the calculate expression w= orks.

Notes on the random() Function:

• If random() is used within a calculate or display condition, the value = will change and be recalculated many time as the form is filled out
• To generate a random number once when the form is opened, add a hidden = value and then put the random() logic inside the Default Value logic of the= hidden value (its in Advanced Section).
• If you're using random() to generate or calculate number that is shown = to the user, then its best practice to put random() inside of the default v= alue section as described above.
------=_Part_26168_905518977.1576110859196--