Files
common/docs/util/modules/_hex_tobn_.md
T
2018-12-21 09:08:40 +00:00

40 lines
1.1 KiB
Markdown

# Functions
<a id="hextobn"></a>
## hexToBn
▸ **hexToBn**(value?: * `string` &#124; `number` &#124; `null`*, options?: * [ToBnOptions](../interfaces/_types_.tobnoptions.md) &#124; `boolean`*): `BN`
*Defined in [hex/toBn.ts:36](https://github.com/polkadot-js/common/blob/5585a16/packages/util/src/hex/toBn.ts#L36)*
*__name__*: hexToBn
*__signature__*: hexToBn (value?: string, \_options: ToBnOptions | boolean = { isLe: false, isNegative: false }): BN
*__summary__*: Creates a BN.js bignumber object from a hex string.
*__description__*: `null` inputs returns a `BN(0)` result. Hex input values return the actual value converted to a BN. Anything that is not a hex string (including the `0x` prefix) throws an error.
*__example__*:
```javascript
import { hexToBn } from '@polkadot/util';
hexToBn('0x123480001f'); // => BN(0x123480001f)
```
**Parameters:**
| Name | Type | Default value |
| ------ | ------ | ------ |
| `Optional` value | `string` &#124; `number` &#124; `null`| - |
| `Default value` options | [ToBnOptions](../interfaces/_types_.tobnoptions.md) &#124; `boolean`| { isLe: false, isNegative: false } |
**Returns:** `BN`
___