> ## Documentation Index
> Fetch the complete documentation index at: https://docs.b3os.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Math Operation

Perform precise mathematical operations (+, -, *, /, %, **) with arbitrary precision. Supports numbers and strings, with configurable rounding (none, floor, ceil, round). No floating-point errors. Ideal for: token calculations, fee computations, threshold checks, percentage calculations.

Catalog action Utility

Perform precise mathematical operations (+, -, *, /, %, **) with arbitrary precision. Supports numbers and strings, with configurable rounding (none, floor, ceil, round). No floating-point errors. Ideal for: token calculations, fee computations, threshold checks, percentage calculations.


## At a Glance

| Field | Value |
| --- | --- |
| Action ID | `math-operation` |
| Category | Utility |
| Connector | Not required |
| Requires gas | No |
| Funds movement | None declared |
| Tags | `math`, `calculation`, `arithmetic`, `blockchain`, `utility`, `precision`, `compute`, `read` |

## Payload Schema

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `left` | `string \| number` | Yes | The left operand \(string or number\) |
| `operator` | `string` | Yes | The mathematical operator to apply |
| `right` | `string \| number` | Yes | The right operand \(string or number\) |
| `rounding` | `string` | Yes | Rounding strategy: 'none' \(keep decimal\), 'floor' \(round down\), 'ceil' \(round up\), 'round' \(round to nearest\) |

## Result Schema

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `left` | `string` | Yes | The left operand value used |
| `operator` | `string` | Yes | The operator used |
| `right` | `string` | Yes | The right operand value used |
| `result` | `string` | Yes | The result as string \(float if rounding='none', integer if rounding specified\) |
| `rounding` | `string` | Yes | The rounding strategy used |
| `expression` | `string` | No | String representation of the operation \(e.g., '5 / 2 = 2.5 \(none\)'\) |

## Examples

**Workflow node**

```json
{
  "type": "math-operation",
  "payload": {
    "left": "example-left",
    "operator": "+",
    "right": "example-right",
    "rounding": "none"
  },
  "children": []
}
```
  **Test with API**

```bash
curl -X POST "https://api.b3os.org/v1/actions/math-operation/test" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "inputs": {
    "left": "example-left",
    "operator": "+",
    "right": "example-right",
    "rounding": "none"
  }
}'
```

**Use expressions for dynamic values**

Payload fields can use workflow expressions such as `{{$trigger.body.amount}}`, `{{$nodes.fetch.result.price}}`, and `{{$props.asset}}` when the value should come from a trigger, prior node, or reusable workflow prop.