# Hex.fromNumber

Encodes a number or bigint into a [`Hex.Hex`](/api/Hex/types#hex) value.

## Imports

:::code-group
```ts [Named]
import { Hex } from 'ox'
```

```ts [Entrypoint]
import * as Hex from 'ox/Hex'
```
:::

## Examples

```ts twoslash
import { Hex } from 'ox'

Hex.fromNumber(420)
// @log: '0x1a4'

Hex.fromNumber(420, { size: 32 })
// @log: '0x00000000000000000000000000000000000000000000000000000000000001a4'
```

## Definition

```ts
function fromNumber(
  value: number | bigint,
  options?: fromNumber.Options,
): Hex
```

**Source:** [src/core/Hex.ts](https://github.com/wevm/ox/blob/main/src/core/Hex.ts#L1003)

## Parameters

### value

* **Type:** `number | bigint`

The number or bigint value to encode.

### options

* **Type:** `fromNumber.Options`
* **Optional**

Options.

#### options.signed

* **Type:** `boolean`
* **Optional**

Whether or not the number of a signed representation.

#### options.size

* **Type:** `number`
* **Optional**

The size (in bytes) of the output hex value.

## Return Type

The encoded [`Hex.Hex`](/api/Hex/types#hex) value.

`Hex`
