Display Numbers to a Specified Precision

You can use the sigform() and decform() functions to display numeric values to a specified number of significant digits or decimal places.

sigform()
Displays a value rounded to the specified number of significant digits. If needed, e notation is used.
The sigform() function is usually used when significant figures are important, such as scientific measurements.
decform()
Displays a value rounded to the specified number of decimal places.
The decform() function is typically used to display like values in the question with a consistent and reasonable precision, for example, to two or three decimal places.
Note If your answer key uses $SIGFIGS or $DECFIGS to require a specified precision, the answer key will be displayed to the correct precision automatically without using the sigform() or decform() functions.
  1. If needed, open your question in the Question Editor.
    If Do this
    You know the question ID or name
    1. In the search box at the top of the page, select Question.
    2. Type the question name or ID and press Enter.
    You own the question
    1. Click Questions > My Questions.
    2. Click the question name.
    You organize your questions in folders
    1. Click Assignments > Folders and navigate to the folder with the question.
    2. Click the question name.
    You want to use advanced search
    1. Click Questions > Search Questions.
    2. Enter the search criteria you want to use.

      To view only your questions, click me next to Author.

    3. Click Search.
    4. If you own the question, click Edit next to your question.

      If you do not own the question, click View, then click Open in Editor under Previewer Tools.

  2. In an <EQN> or <eqn> tag, use either the sigform() or decform() function to display a numeric value.
    To do this Do this
    Specify the number of significant digits

    Use the following syntax:

    sigform(n, digits)

    where n is the number you want to format, and digits is a positive integer specifying the number of significant digits to use.

    Specify the number of decimal places

    Use the following syntax:

    decform(n, digits)

    where n is the number you want to format, and places is a non-negative integer specifying the number of decimal places to use.

    For example:

    # sigform examples
    
    $shortpi = sigform($pi,3);   #  3.14
    $a = sigform(100,1)          #  100
    $b = sigform(100,2)          #  1.0e+02
    
    #decform examples
    
    $shortpi = decform($pi,3);   #  3.142
    $a = decform(100,1)          #  100.0
    $b = decform(100,2)          #  100.00

Example Question Using sigform()

The following table summarizes an actual question.

QID

1940827

Name

Mode

Numerical

Question

<eqn>
# Pick two different significant figures for the measurements
($m_sigfigs,$v_sigfigs) = pick(2,2..5);

# Randomize measurements & round to the specified significant figures
$mass = sigform(randnum(300000,1200000,1)/100000,$m_sigfigs);
$volume = sigform(randnum(106000,110000,1)/100000,$v_sigfigs);

# Calculate answer key and determine correct significant figures
$density = $mass/$volume;
$d_sigfigs = min($m_sigfigs,$v_sigfigs);

''
</eqn>
In the lab, you measure the displacement of a metal sphere as <eqn $volume> liters.<BR/>
You also determine its mass to be <eqn $mass> kg.<BR/>
Calculate its density. <_> kg/l

Answer

<EQN $SIGFIGS=$d_sigfigs; $density> 

Display to Students

Question as displayed to students

Example Question Using decform()

The following table summarizes an actual question.

QID

1944303

Name

Mode

Numerical

Question

<eqn>
# Pick the number of decimal places for the problem
($decimals) = pick(1,2..4);

# Randomize addends
$a = decform(randnum(100000,999999,1)/10000,$decimals);
$b = decform(randnum(100000,999999,1)/10000,$decimals);

''
</eqn>
<watex>\begin{array}{r}
$a \\
+ $b \\
\cline{0-0} <_>
\end{array}</watex>

Answer

<EQN $SIMPLIFIED=1; decform($a + $b, $decimals)> {tab} 0

Display to Students

Question as displayed to students
Tip For known constants, you can enclose the value in single quotes to store both the value and the precision with which you specified it. For example, $e = '2.718'; assigns a value to $e with four significant digits.