# DecimalFormat

Converts a number to a decimal-formatted string.

## Method Signature

```
DecimalFormat(number=[any], length=[integer])
```

### Arguments

| Argument | Type      | Required | Description                                                      | Default |
| -------- | --------- | -------- | ---------------------------------------------------------------- | ------- |
| `number` | `any`     | `true`   | The number to convert to decimal format.                         |         |
| `length` | `integer` | `false`  | The number of decimal places to include in the formatted string. | `2`     |

## Examples

### Formatting examples

[Run Example](https://try.boxlang.io/?code=eJxLyy%2FKTSwpSU3xzCtRsFVISU3OzE3McQOLaigYGhkraFor6OuDWHoGBlzlRZklqf6lJQWlQNk0ZL1qCko2SUV2SkD1XHCJ8MySjODUgsSixJL8omIs5huAAcwOHSAbhHHbhGYgVktdIHZg2mZpYa5naAq1DMLBYQ3MCKzmB%2BWX5qWkpoQWYNpgYmqmZ25hCbUCzLNU0FUoAukoVigtwGEdwkRkCwEqj4HW)

```java
formattedInt = decimalFormat( 123 ); // 123.00
writeOutput( formattedInt & "<br>" );
formattedWithSeparators = decimalFormat( 1000000 ); // 1,000,000.00
writeOutput( formattedWithSeparators & "<br>" );
formattedDecimal = decimalFormat( 987.15 ); // 987.15
writeOutput( formattedDecimal & "<br>" );
formattedRoundedUp = decimalFormat( 456.789 ); // 456.79 - rounds up
writeOutput( formattedRoundedUp & "<br>" );

```

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJwrL8osSfUvLSkoLdFQSElNzsxNzHHLL8pNBHKVTEyVFDQV1BSUbJKK7IBMawV9fQUTUz0DA65yPPqMzIC6NK25QKqNzICqrbkAdSIdMg%3D%3D)

```java
writeOutput( decimalFormat( "45" ) & "<br>" ); // 45.00
writeOutput( decimalFormat( 26 ) );
 // 26.00;

```

## Related

* [BooleanFormat](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/format/booleanformat)
* [LSNumberFormat](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/format/lsnumberformat)
* [NumberFormat](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/format/numberformat)


---

# 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://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/format/decimalformat.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.
