# equation (=)

##### Sample Usage

a) {= sqrt(49) * log(10)/2}
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. |

Refer to the Blaze Equation Language reference for more information on defining the test condition.

See also the `if`

command and the `repeat`

command for additional tools to help you build dynamic snippets.

## Output Number Formatting

The optional `format`

attribute allows you to control how numeric outputs are formatted in equations.

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