Skip to content
On this page

formatUnit

Divides a number by a given exponent of base 10 (10exponent), and formats it into a string representation of the number.

Import

ts
import { formatUnit } from 'viem/utils'

Usage

ts
import { formatUnit } from 'viem/utils'

formatUnit(420000000000n, 9) 
// '420'

Returns

string

Parameters

value

  • Type: bigint

The number to divide.

exponent

  • Type: number

The exponent.

Released under the MIT License.