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