This function formats values to a specified number of significant digits.
export function formatSignificant(bigNumberish: BigNumberish, options?: FormatSignificantOptions): string
Parameter | Type | Description |
---|---|---|
bigNumberish | BigNumberish | The value to be formatted. |
options? | FormatSignificantOptions | Formatting options. |
const formatted: string = formatSignificant('123456', { significantDigits: 3 }) // 1.23
This function formats token and ethereum values to a specified number of significant digits.
export function formatSignificantDecimals(bigNumberish: BigNumberish,decimals: number,options?: FormatSignificantOptions): string
Parameter | Type | Description |
---|---|---|
bigNumberish | BigNumberish | The value to be formatted. |
decimals | number | The decimals of the passed value. |
options? | FormatSignificantOptions | Formatting options. |
const formatted: string = formatSignificantDecimals('1234560000000000000', 18, { significantDigits: 3 }) // 1.23
This function formats values to a specified number of decimal places.
export function formatFixed(bigNumberish: BigNumberish, options?: FormatFixedOptions): string
Parameter | Type | Description |
---|---|---|
bigNumberish | BigNumberish | The value to be formatted. |
options? | FormatFixedOptions | Formatting options. |
const formatted: string = formatFixed('1.2345', { decimalPlaces: 2 }) // 1.23
This function formats token and ethereum values to a specified number of decimal places.
export function formatFixedDecimals(bigNumberish: BigNumberish, decimals: number, options?: FormatFixedOptions): string
Parameter | Type | Description |
---|---|---|
bigNumberish | BigNumberish | The value to be formatted. |
decimals | number | The decimals of the passed value. |
options? | FormatFixedOptions | Formatting options. |
const formatted: string = formatFixedDecimals('1234560000000000000', 18, { decimalPlaces: 2 }) // 1.23