Skip to main content
Helpful?

formatSignificant

This function formats values to a specified number of significant digits.

Function Signature

export function formatSignificant(bigNumberish: BigNumberish, options?: FormatSignificantOptions): string

Input Parameters

ParameterTypeDescription
bigNumberishBigNumberishThe value to be formatted.
options?FormatSignificantOptionsFormatting options.

Example Usage

const formatted: string = formatSignificant('123456', { significantDigits: 3 }) // 1.23

formatSignificantDecimals

This function formats token and ethereum values to a specified number of significant digits.

Function Signature

export function formatSignificantDecimals(
bigNumberish: BigNumberish,
decimals: number,
options?: FormatSignificantOptions
): string

Input Parameters

ParameterTypeDescription
bigNumberishBigNumberishThe value to be formatted.
decimalsnumberThe decimals of the passed value.
options?FormatSignificantOptionsFormatting options.

Example Usage

const formatted: string = formatSignificantDecimals('1234560000000000000', 18, {
significantDigits: 3,
}) // 1.23

formatFixed

This function formats values to a specified number of decimal places.

Function Signature

export function formatFixed(bigNumberish: BigNumberish, options?: FormatFixedOptions): string

Input Parameters

ParameterTypeDescription
bigNumberishBigNumberishThe value to be formatted.
options?FormatFixedOptionsFormatting options.

Example Usage

const formatted: string = formatFixed('1.2345', { decimalPlaces: 2 }) // 1.23

formatFixedDecimals

This function formats token and ethereum values to a specified number of decimal places.

Function Signature

export function formatFixedDecimals(bigNumberish: BigNumberish, decimals: number, options?: FormatFixedOptions): string

Input Parameters

ParameterTypeDescription
bigNumberishBigNumberishThe value to be formatted.
decimalsnumberThe decimals of the passed value.
options?FormatFixedOptionsFormatting options.

Example Usage

const formatted: string = formatFixedDecimals('1234560000000000000', 18, {
decimalPlaces: 2,
}) // 1.23
Helpful?