Define numeric variables with functions

Updated 30 Aug 2024

You can use any of the following functions when defining the minimum and maximum fields for a numeric variable or in an answer box.

Function Format Purpose & Example
rand rand(range-start,range-end,exponent) Purpose:
Generates a random number within a specified range, optionally rounded to a specific power of 10.

Example:
rand(10,100,1) randomly returns 10, 20, 30, ...100. The default value for exponent is 0; that is, the value returned is rounded to the nearest integer.

round round(value,exponent) Purpose:
Rounds a value to a specific power of 10.

Example:
round(1.2345,-3) returns 1.235.

sigdig sigdig(value,exponent) Purpose: Rounds a value to a specific number of significant digits.

Example:
sigdig(1.2345,3) returns 1.23.

ifthenelse ifthenelse(test,true_value,false_value) Purpose:
Returns one of two values depending on the result of a logical test.

Example:
ifthenelse(x>y,x,y) returns x if x is larger; otherwise it returns y. See below for sample values.

 

 

See also: