Referencenumber

<number>

A numeric floating point value

<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)
avoidScientificNotation

boolean. 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: \(\left( 0, 0 \right)\). Coordinates of the anchor point used to position this component on a graph.

positionFromAnchor

keyword. Where this component sits relative to its anchor point.

ValueDescription
upperRightPlace the component above and to the right of the anchor point.
upperLeftPlace the component above and to the left of the anchor point.
lowerRightPlace the component below and to the right of the anchor point.
lowerLeftPlace the component below and to the left of the anchor point.
topPlace the component directly above the anchor point.
bottomPlace the component directly below the anchor point.
leftPlace the component directly to the left of the anchor point.
rightPlace 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.

layer

number. 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)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. 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.avoidScientificNotation

boolean. Whether to render numbers in full decimal form rather than scientific notation.

$n.displayDecimals

integer. Number of decimal places to display when rendering this number.

$n.displayDigits

integer. Number of significant digits to display when rendering this number.

$n.displaySmallAsZero

number. Threshold below which numbers are displayed as zero.

$n.padZeros

boolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Positioning (2)
$n.anchor

point. The coordinates where this component is anchored on the graph.

$n.positionFromAnchor

text. Where this component sits relative to its anchor point.

Other (14)
$n.backgroundColor

text. Human-readable name for this component's background color, derived from the active style and theme.

$n.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$n.draggable

boolean. Whether the number can be dragged on a graph.

$n.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$n.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$n.hidden

boolean. Whether this component is hidden from the rendered output.

latex. The number rendered as LaTeX.

$n.layer

number. Z-order layer index when shown on a graph.

$n.math

math. The number's value as a math expression.

$n.renderAsMath

boolean. Whether to render the number using math typography.

$n.text

text. The number rendered as plain text.

$n.textColor

text. Human-readable name for this component's text color, derived from the active style and theme.

$n.textStyleDescription

text. Human-readable description of this component's text styling (color and any background color).

number. The numeric value.

Common to all components (4)
$n.doenetML

text. The DoenetML source code that produced this component.

$n.hide

boolean. Whether to hide this component from the rendered output.

$n.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$n.styleNumber

integer. 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 101410^{-14}, 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>.