The following list includes both WebAssign-specific and commonly-used Perl functions that are available when creating questions.
Rounding, Significant Digits, Scientific Notation
Operation |
Usage |
Notes |
---|---|---|
Round to specified decimal places |
|
Returns n rounded to the specified number of decimal places. |
Round up (next greater integer) |
|
Returns the first integer greater than n, for example, ceil(23.2) is 24, ceil(-23.7) is -23. |
Round down (next lesser integer) |
|
Returns the first integer less than n, for example, floor(23.7) is 23, floor(-23.2) is - 24. |
Return integer only |
|
Returns only the integer component of n, for example, int(23.7) is 23, int(-23.2) is - 23. |
Get significant digits |
|
Returns the number of significant digits in n, ignoring trailing zeros. |
Display significant digits |
|
Returns n rounded to the specified number of significant
digits. Uses |
Get decimal places |
|
Returns a power of 10 that represents the smallest significant decimal place in n. Ignores trailing zeros. |
Display scientific notation |
|
Returns n formatted as scientific notation with the specified number of significant digits, for example 2.31 × 104. Do not use results for additional computation. |
Display |
|
Returns n in |
Display of Numerical Values
The listed functions are mostly used in Question or Solution to format values for display.
Operation |
Usage |
Notes |
---|---|---|
Reduced fraction |
|
Returns the fraction n/d in reduced form, for
example, 1/2 or 1. If used in Answer, specify
|
Rounded integer |
|
Returns n rounded to the nearest integer. Uses |
Add commas |
|
Returns n with commas between digit groups to the left of the decimal point, for example, 12,345.678901. Do not use results for additional computation. |
Add spaces |
|
Returns n with spaces between digit groups on both sides of the decimal point, for example, 12 345.678 901. Do not use results for additional computation. |
Display as words |
|
Returns the integer part of n in words, for example, |
Display as words (ordinal) |
|
Returns the integer part of n as an ordinal number in words, for
example, |