# Divide

Divide behaves differently according to the type of the LHS:

* strings: split by the divider
* number: arithmetic division

## String split

Given a sample.yml file of:

```yaml
a: cat_meow
b: _
```

then

```bash
yq '.c = .a / .b' sample.yml
```

will output

```yaml
a: cat_meow
b: _
c:
  - cat
  - meow
```

## Number division

The result during division is calculated as a float

Given a sample.yml file of:

```yaml
a: 12
b: 2.5
```

then

```bash
yq '.a = .a / .b' sample.yml
```

will output

```yaml
a: 4.8
b: 2.5
```

## Number division by zero

Dividing by zero results in +Inf or -Inf

Given a sample.yml file of:

```yaml
a: 1
b: -1
```

then

```bash
yq '.a = .a / 0 | .b = .b / 0' sample.yml
```

will output

```yaml
a: !!float +Inf
b: !!float -Inf
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mikefarah.gitbook.io/yq/operators/divide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
