Skip to content
On this page

formatUnits โ€‹

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

Import โ€‹

ts
import { formatUnits } from 'viem'

Usage โ€‹

ts
import { formatUnits } from 'viem'

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

Returns โ€‹

string

Parameters โ€‹

value โ€‹

  • Type: bigint

The number to divide.

exponent โ€‹

  • Type: number

The exponent.

Released under the MIT License.