> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/formatbasen.md).

# FormatBaseN

Converts a number to a string representation in the specified base.

## Method Signature

```
FormatBaseN(number=[numeric], radix=[integerTruncate])
```

### Arguments

| Argument | Type              | Required | Description | Default |
| -------- | ----------------- | -------- | ----------- | ------- |
| `number` | `numeric`         | `true`   |             |         |
| `radix`  | `integerTruncate` | `true`   |             |         |

## Examples

### Format 10 as dual number

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

```java
formatBaseN( 10, 2 );

```

Result: 1010

### Format 1024 as hexadecimal number

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

```java
formatBaseN( 1024, 16 );

```

Result: 400

### Format 125 as decimal number

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

```java
formatBaseN( 125, 10 );

```

Result: 125

### Format a float

Floors float to integer then formats with radix given

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

```java
formatBaseN( 10.75, 2 );

```

Result: 1010

### Additional Examples

```java
<bx:output>
  #formatBaseN( 15, 2 )# <!--- 1111 (binary) ---> 
  #formatBaseN( 15, 16 )# <!--- f (hexadecimal) ---> 
  #formatBaseN( 15, 8 )# <!--- 17 (octal) ---> 
</bx:output>
```

```java
<bx:set max = CreateObject( "java", "java.lang.Integer" ).MAX_VALUE >
<bx:output>
  #formatBaseN( max, 16 )# <!--- 7fffffff (correct) ---> 
  #formatBaseN( max + 1, 16 )# <!--- 7fffffff (incorrect) ---> 
</bx:output>
```

## Related

* [Abs](/boxlang-language/reference/built-in-functions/math/abs.md)
* [Acos](/boxlang-language/reference/built-in-functions/math/acos.md)
* [Asin](/boxlang-language/reference/built-in-functions/math/asin.md)
* [Atn](/boxlang-language/reference/built-in-functions/math/atn.md)
* [Ceiling](/boxlang-language/reference/built-in-functions/math/ceiling.md)
* [Cos](/boxlang-language/reference/built-in-functions/math/cos.md)
* [DecrementValue](/boxlang-language/reference/built-in-functions/math/decrementvalue.md)
* [Exp](/boxlang-language/reference/built-in-functions/math/exp.md)
* [Fix](/boxlang-language/reference/built-in-functions/math/fix.md)
* [Floor](/boxlang-language/reference/built-in-functions/math/floor.md)
* [IncrementValue](/boxlang-language/reference/built-in-functions/math/incrementvalue.md)
* [InputBaseN](/boxlang-language/reference/built-in-functions/math/inputbasen.md)
* [Int](/boxlang-language/reference/built-in-functions/math/int.md)
* [Log](/boxlang-language/reference/built-in-functions/math/log.md)
* [Log10](/boxlang-language/reference/built-in-functions/math/log10.md)
* [Max](/boxlang-language/reference/built-in-functions/math/max.md)
* [Min](/boxlang-language/reference/built-in-functions/math/min.md)
* [Pi](/boxlang-language/reference/built-in-functions/math/pi.md)
* [PrecisionEvaluate](/boxlang-language/reference/built-in-functions/math/precisionevaluate.md)
* [Rand](/boxlang-language/reference/built-in-functions/math/rand.md)
* [Randomize](/boxlang-language/reference/built-in-functions/math/randomize.md)
* [RandRange](/boxlang-language/reference/built-in-functions/math/randrange.md)
* [Round](/boxlang-language/reference/built-in-functions/math/round.md)
* [Sgn](/boxlang-language/reference/built-in-functions/math/sgn.md)
* [Sin](/boxlang-language/reference/built-in-functions/math/sin.md)
* [Sqr](/boxlang-language/reference/built-in-functions/math/sqr.md)
* [Tan](/boxlang-language/reference/built-in-functions/math/tan.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/math/formatbasen.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.
