# ToNumeric

Cast a value to a number.

## Method Signature

```
ToNumeric(value=[string], radix=[any])
```

### Arguments

| Argument | Type     | Required | Description                                                                                     | Default |
| -------- | -------- | -------- | ----------------------------------------------------------------------------------------------- | ------- |
| `value`  | `string` | `true`   | The value to cast.                                                                              |         |
| `radix`  | `any`    | `false`  | The radix to use when casting the value. Valid values are 2-36, "bin", "oct", "dec", and "hex". |         |

## Examples

### Cast a string to a number.

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

```java
toNumeric( "29.5" );

```

Result: 29.5

### Cast a hex-value to a number.

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

```java
toNumeric( "FF0011", "hex" );

```

Result: 16711697

### Cast a binary-value to a number.

[Run Example](https://try.boxlang.io/?code=eJwryfcrzU0tykzWUFAyNDA0UNJRUErKzFNS0LTmAgB8WAdc)

```java
toNumeric( "1010", "bin" );

```

Result: 10

### Additional Examples

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

```java
writeDump( toNumeric( "123.45" ) );
writeDump( toNumeric( "0110", "bin" ) ); // 6
writeDump( toNumeric( "000C", "hex" ) ); // 12
writeDump( toNumeric( "24", "oct" ) );
 // 30

```

## Related

* [DataNavigate](/boxlang-language/reference/built-in-functions/conversion/datanavigate.md)
* [JSONDeserialize](/boxlang-language/reference/built-in-functions/conversion/jsondeserialize.md)
* [JSONPrettify](/boxlang-language/reference/built-in-functions/conversion/jsonprettify.md)
* [JSONSerialize](/boxlang-language/reference/built-in-functions/conversion/jsonserialize.md)
* [LSParseNumber](/boxlang-language/reference/built-in-functions/conversion/lsparsenumber.md)
* [ParseNumber](/boxlang-language/reference/built-in-functions/conversion/parsenumber.md)
* [ToBase64](/boxlang-language/reference/built-in-functions/conversion/tobase64.md)
* [ToBinary](/boxlang-language/reference/built-in-functions/conversion/tobinary.md)
* [ToModifiable](/boxlang-language/reference/built-in-functions/conversion/tomodifiable.md)
* [ToScript](/boxlang-language/reference/built-in-functions/conversion/toscript.md)
* [ToString](/boxlang-language/reference/built-in-functions/conversion/tostring.md)
* [ToUnmodifiable](/boxlang-language/reference/built-in-functions/conversion/tounmodifiable.md)


---

# 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/conversion/tonumeric.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.
