Skip to content

Hex.fromNumber

Encodes a number or bigint into a Hex.Hex value.

Imports

Named
import { Hex } from 'ox'

Examples

import { Hex } from 'ox'
 
Hex.fromNumber(420)
'0x1a4'
Hex.fromNumber(420, { size: 32 })
'0x00000000000000000000000000000000000000000000000000000000000001a4'

Definition

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

Source: src/core/Hex.ts

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 value.

Hex