Formulas: More examples
Significant figures
"The significant figures of a number are digits that carry meaning contributing to its measurement resolution." (Reference: https://en.wikipedia.org/wiki/Significant_figures).
The Formulas question has no built-in function to display numbers with a given number of significant figures. However, it is easy to work out this function as the following variable assignment which works with any real number:
xr=x==0?x:round(x*pow(10,nsf-1-floor(log10(abs(x)))),0)*pow(10,-nsf+1+floor(log10(abs(x))));
where x is the number to be rounded, nsf the number of significant digits to keep and xr the resulting rounded value.
This example deals with the display of the correct answers with different numbers of significant figures.
The Formulas question should look like this:
Play it Login info (Open in new tab: Ctrl+Shift+Click)
This example is a significant figures drill.
General Question name! Significant figures drill Variables Random variables # a plus or minus sign # b exponent varying from -4 to 4 in steps of 0.01 # rnsf random number of significant figures : 1, 2, 3, or 4 a={-1,1}; b={-4:4.01:0.01}; rnsf={1,2,3,4}; Global variables # nx number x = ± 10^b nx=a*pow(10,b); # Rounding routine: # x number to round # nsf number of significant figures # xr rounded value of x x=nx; nsf=rnsf; xr=x==0?x:round(x*pow(10,nsf-1-floor(log10(abs(x)))),0)*pow(10,-nsf+1+floor(log10(abs(x)))); Main question Question text! Significant figures drill Part 1 Part's mark* 1 Answer type Number Answer* xr Grading criteria* Relative error < 0.0001 Part's text Number to round: {nx} Number of significant digits to keep: {ncs} Rounded number: {_0} Combined feedback For any correct response The correct answer is: {xr} For any incorrect response The correct answer is: {xr}
The Formulas question should look like this:
Play it Login info (Open in new tab: Ctrl+Shift+Click)