Skip to main content

fromTwosComplement

Callable

  • fromTwosComplement(value: Numbers, nibbleWidth?: number): number | bigint

  • Converts the twos complement into a decimal number or big int.

    @example
    console.log(web3.utils.fromTwosComplement('0x0000000000000000000000000000000d', 32'));
    > 13

    console.log(web3.utils.fromTwosComplement('0x00000000000000000020000000000000', 32));
    > 9007199254740992n

    Parameters

    • value: Numbers

      The value to be converted.

    • nibbleWidth: number = 64

      The nibble width of the hex string (default is 64).

    Returns number | bigint

    The decimal number or big int.