# equation (=)

##### Sample Usage

b) {= 73 / 51; format=$0.2f}

c) {formtext: name=x; default=4} * {formtext: name=y; default=3} = {= x * y}

d) {= 81 >= 23}

## Attributes

Attribute Name | Type | Description |
---|---|---|

Positional | equation | The mathematical or programmatic equation. |

format | text | How to format the numeric output of the equation. |

trim | yes/no/left/right | If `yes` whitespace is removed before and after the command. If `left` , only whitespace to the left is removed. If `right` , only whitespace to the right is removed. |

See the Blaze Equation Language reference for more information on the features supported in equations.

See also the `{if}`

command and the `{repeat}`

command for additional tools to help you build dynamic snippets.

## Assignment Mode

The equation command can also be used to assign form values which can then be used in your other equations. To use it this way, put the name of a form variable before the equation command's `=`

sign. When used in assignment mode, the equation command won't display any output.

##### Assigning Form Values with Equations

## Output Number Formatting

The optional `format`

attribute allows you to control how numeric outputs are formatted in equations. The formatting will attempt to use the user's locale specified in the Text Blaze settings.

The format syntax is the same as that used by D3. To summarize, the format is defined in this way:

`[[fill]align][sign][symbol][0][width][,][.precision][type]`

More information and examples on formatting can be found here and here.

It useful to see examples of format definitions and the resulting outputs. The following table shows how different formats would be applied to different sample numbers.

Format | Applied to `0.934` | Applied to `1245.67` |
---|---|---|

s | 934.2m | 1.24567k |

, | 0.9342 | 1,245.67 |

,% | 93% | 124,567% |

+, | +0.9342 | +1,245.67 |

.3r | 0.934 | 1250 |

.3n | 0.934 | 1.25e+3 |

.0f | 1 | 1246 |

.1f | 0.9 | 1245.7 |

.1e | 9.3e-1 | 1.2e+3 |

$,.0f | $1 | $1,246 |