# Number Edits¶

*Number edits* display numeric values and are the main control to edit numeric values (a lot of things in smile2 are numbers).

Number edits can be used for editing of “general” internal values, or for *plugs* (these plug controls are usually located in the Attribute Editor.

## General¶

### Display and editing¶

Number edits display floating point numbers always in decimal format with a fixed precision, depending on the type of the value
(eg. measures in **µm** are usually displayed with an accuracy of one nanometer).

Note

The precision is just a “display feature”. Internally, the numbers are stored with full accuracy.

Once, the user starts to edit a number, the background of the control changes to blue. This indicates that the change is “pending” and
has not yet been applied. To commit a change, either press `Enter` or leave the control by clicking to an other ui element or using
the `TAB` key to change the focus. If the input is accepted, the background changes again to the standard color and the new number is displayed.
If the input is rejected (eg. it is out of bounds, or an error happened in the evaluation of an expression), the background turns red, and the string
“Error” is shown. After two seconds, the number edit displays the old value again with a standard background color.

### Expressions¶

You can also enter mathmatical expressions such as `4*4`

or `4^2`

instead of `16`

.
Also functions like `sqrt(2)`

(square root of 2) or `sin(3.141)`

may be used.
All supported functions are: `sqrt()`

, `sin()`

, `cos()`

, `asin()`

, `acos()`

, `tan()`

, `atan()`

,
`sinh()`

, `cosh()`

, `asinh()`

, `acosh()`

, `tanh()`

, `atanh()`

. `exp()`

, `log10()`

, `log()`

, `abs()`

.

The following operators may be used: `+`

, `-`

, `*`

, `/`

, `^`

.

To encapsulete terms, the `(`

, `)`

brackets can be used.

## Number edits in plug controls¶

Number edits are not only used for floating point and integer numbers, but for all *plug types* that break down to numbers (eg, vec2, mat3, square, rect, …).

Beside the behavior described above, *number edits* that display plugs (or sub-plugs) have some extended functionality, described in the following sections.

### Expression Extensions¶

In plug controls, mathematical expressions can also be used to reference other plugs or plugs of other nodes. The general format for this is `{objectname}.{plugname}`

.
To reference a plug of the same node, the `{objectname}`

can be omitted.
As an examples, one could write in the y-component of the translation plug the following equation: `20*sin(rotation/180*3.141)`

. The “rotation” plug name can
also be written in shorter form: `20*sin(r/180*3.141)`

(the name can be shortened as far as it still stays unique eg. for scale one would need to write at least “sc”, since
“s” collides with “shear”). To reference a plug from an other node, the **object name** of this node must be specified (and unique). Eg. one could write in the y-component of the translation plug the following equation:
`2*myOtherTrans.trans.x`

.

The expressions above, simply set the calculated value to the corresponding plot. However one could go one step further and create connections with expressions.
For this, the expression need sto start with a `=`

. Eg. writing `=rotation`

in the y-component of the translation plug connect the output of the rotation plug to theseinput of
the translations y-coordinate. Non trivial expressions like `=rot*5/tr.x`

create an intermediate :doc:`/nodes/ExpressionNode`

to permanently
evaluate the expression whenever the rotation or the x-coordinate of the translation changes.

### Plug connections with Drag-and-Drop¶

Further information about plugs and the attribute editor can be found in the Attribute Editor chapter.