@jonahsnider/util

    Function and

    • Calculate the bitwise AND of 2 numbers. Meant to be used with Array.prototype.reduce.

      Time complexity: O(1)

      Space complexity: O(1)

      Parameters

      • a: number

        First operand

      • b: number

        Second operand

      Returns number

      The bitwise AND of a and b

      Reducers

      const array = [5, 3];

      array.reduce(Bitwise.and); // 1
    • Calculate the bitwise AND of 2 bigints. Meant to be used with Array.prototype.reduce.

      Time complexity: O(1)

      Space complexity: O(1)

      Parameters

      • a: bigint

        First operand

      • b: bigint

        Second operand

      Returns bigint

      The bitwise AND of a and b

      Reducers

      const array = [5n, 3n];

      array.reduce(Bitwise.and); // 1n
    MMNEPVFCICPMFPCPTTAAATR