Skip to content

toBigInt api? #18

@elee1766

Description

@elee1766

i use dnum to go from token amount in decimals -> absolute token amount.

this is usually done by doing something like

const n = dnum.multiply(dnum.from(decimalAmount), 10n ** BigInt(decimals))

then i need to get the floor of this number as a bigint, to pass to viem, so i do

const bigIntValue = n[0] / 10n ** BigInt(n[1])

it would be useful if there was perhaps an api like.

toBigInt(n:Numberish): bigint


// usage:
const bigIntValue = dnum.toBigInt(n)

would you be open to a PR with something like this? or is there an existing function that i can use to do the same task?

dnum.from(n, 0)[0] maybe? (it seems sort of cursed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions