<number>
<number> is a Math
component that calculates a numerical (floating point) value from its contents
and displays the result as text.
The default precision for display is either: (1) rounded to three significant digits or (2) rounded two decimal places, whichever has more digits.
Attributes and Properties
Attributes for <number>
Number display (5)
avoidScientificNotationboolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.
integer. Default value: 2. Number of decimal places to display when rendering this number.
integer. Default value: 3. Number of significant digits to display when rendering this number.
number. Default value: 1e-14. Threshold below which numbers are displayed as zero.
boolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Positioning (2)
point. Default value: . Coordinates of the anchor point used to position this component on a graph.
positionFromAnchorkeyword. Where this component sits relative to its anchor point.
| Value | Description |
|---|---|
upperRight | Place the component above and to the right of the anchor point. |
upperLeft | Place the component above and to the left of the anchor point. |
lowerRight | Place the component below and to the right of the anchor point. |
lowerLeft | Place the component below and to the left of the anchor point. |
top | Place the component directly above the anchor point. |
bottom | Place the component directly below the anchor point. |
left | Place the component directly to the left of the anchor point. |
right | Place the component directly to the right of the anchor point. |
center (default) | Center the component on the anchor point. |
Other (5)
boolean. Default value: false. Whether to convert boolean inputs to 1/0 instead of NaN.
boolean. Default value: true. Whether the number can be dragged on a graph.
layernumber. Default value: 0. Z-order layer index when shown on a graph.
boolean. Default value: false. Whether to render the number using math typography.
number. Default value: NaN. Numeric value to use when the input cannot be parsed.
Common to all components (9)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. Default value: 1. The style number used to select this component's visual styling from the available style definitions.
Properties for <number name="n">
Number display (5)
$n.avoidScientificNotationboolean. Whether to render numbers in full decimal form rather than scientific notation.
$n.displayDecimalsinteger. Number of decimal places to display when rendering this number.
$n.displayDigitsinteger. Number of significant digits to display when rendering this number.
$n.displaySmallAsZeronumber. Threshold below which numbers are displayed as zero.
$n.padZerosboolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Positioning (2)
$n.anchorpoint. The coordinates where this component is anchored on the graph.
$n.positionFromAnchortext. Where this component sits relative to its anchor point.
Other (14)
$n.backgroundColortext. Human-readable name for this component's background color, derived from the active style and theme.
$n.disabledboolean. Whether this component is disabled and cannot be interacted with.
$n.draggableboolean. Whether the number can be dragged on a graph.
$n.fixedboolean. Whether this component's value is fixed and cannot be modified.
$n.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$n.latexlatex. The number rendered as LaTeX.
$n.layernumber. Z-order layer index when shown on a graph.
$n.mathmath. The number's value as a math expression.
$n.renderAsMathboolean. Whether to render the number using math typography.
$n.texttext. The number rendered as plain text.
$n.textColortext. Human-readable name for this component's text color, derived from the active style and theme.
$n.textStyleDescriptiontext. Human-readable description of this component's text styling (color and any background color).
$n.valuenumber. The numeric value.
Common to all components (4)
$n.doenetMLtext. The DoenetML source code that produced this component.
$n.hideboolean. Whether to hide this component from the rendered output.
$n.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$n.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: Display numerical approximation
The default precision for display is either (1)rounded to three significant digits or (2) rounded two decimal places, whichever has more digits.
Attribute Examples
Attribute Example: renderAsMath
The renderAsMath attribute adjusts the default font for a <number> in order
for it to appear the same as that of a <math>.
The same effect can be achieved by placing the <number> inside a <m> component,
as shown in the last paragraph of the example above.
Attribute Example: convertBoolean
The convertBoolean attribute renders or stores a boolean that evaluates to true as 1 and to false as 0.
Attribute Example: valueOnNaN
The valueOnNaN attribute allows for temporary values (which can be used in boolean conditions) to
be stored by Doenet until a new number is assigned
Attribute Example: anchor
The anchor attribute sets the location of a <number> placed within a <graph>.
Attribute Example: draggable
The draggable attribute determines whether the <number> can be
dragged around the <graph>. All graphical objects are draggable by default.
Attribute Example: displayDigits/displayDecimals
By default, numbers will be displayed as rounded to three digits or to two
decimal places, whichever includes more digits. The displayDigits attribute will
change the number of digits, and the displayDecimals attribute will
change the number of decimal places.
Note: these display rounding settings do not affect the actual value of the
numbers in the expression. All available digits will be used if the expression
is used in another calculation unless one uses the <round> component to explicitly round numbers.
Attribute Example: displaySmallAsZero
The default value of the displaySmallAsZero attribute is , which means that
numerical values smaller than that value will appear as zero. This behavior can be
altered by changing the value of displaySmallAsZero to a different number, or even setting it to “false”.
Attribute Example: padZeros
If the padZeros is set, then numbers will be displayed padded with zeros so
that all the digits from the combination of displayDigits and displayDecimals will be shown.
Property Examples
Property Example: value
The value property renders the value stored in the <number>.
Property Example: text
The text property renders the text value stored in the <number>.
Property Example: latex
The latex property renders the latex code for rendering the <number>.