6.12 Tutorial: Formatting Integers and Reals
This tutorial demonstrates the effect of applying various formatting options to the same expression in a question.
Consider a question that contains the text:
A dog weighs $m kg.
The following table shows how different assignments of values to $m are interpreted.
Table 6.11: Formatting Numbers with $m
Syntax | Format Display |
---|
$m=15.27375491 | A dog weighs 15.27375491 kg. |
$m=sig(3, 15.27375491) | A dog weighs 15.3 kg. |
$m=int(15.27375491) | A dog weighs 15 kg. |
$m=decimal(1, 15.27375491) | A dog weighs 15.3 kg. |
$m=decimal(0, 15.27375491) | A dog weighs 15 kg. |
decimal(n, x)
Returns x expressed as a floating-point number rounded to n decimal places.
sig(n, x)
Returns x expressed as a floating-point number rounded to n significant digits.
int(x)
Returns the integer part of x.