Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Bitwise

Index

Functions Reducers

Reducers Functions

  • and(a: number, b: number): number
  • and(a: bigint, b: bigint): bigint
  • Calculate the bitwise AND of 2 numbers. Meant to be used with Array.prototype.reduce.

    Time complexity: O(1)

    Space complexity: O(1)

    example
    const array = [5, 3];

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

    Parameters

    • a: number

      First operand

    • b: number

      Second operand

    Returns number

    The bitwise AND of a and b

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

    Time complexity: O(1)

    Space complexity: O(1)

    example
    const array = [5n, 3n];

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

    Parameters

    • a: bigint

      First operand

    • b: bigint

      Second operand

    Returns bigint

    The bitwise AND of a and b

  • or(a: number, b: number): number
  • or(a: bigint, b: bigint): bigint
  • Calculate the bitwise OR of 2 numbers. Meant to be used with Array.prototype.reduce.

    Time complexity: O(1)

    Space complexity: O(1)

    example
    const array = [5, 3];

    array.reduce(Bitwise.or); // 7

    Parameters

    • a: number

      First operand

    • b: number

      Second operand

    Returns number

    The bitwise OR of a and b

  • Calculate the bitwise OR of 2 bigints. Meant to be used with Array.prototype.reduce.

    Time complexity: O(1)

    Space complexity: O(1)

    example
    const array = [5n, 3n];

    array.reduce(Bitwise.or); // 7n

    Parameters

    • a: bigint

      First operand

    • b: bigint

      Second operand

    Returns bigint

    The bitwise OR of a and b

  • xor(a: number, b: number): number
  • xor(a: bigint, b: bigint): bigint
  • Calculate the bitwise XOR of 2 numbers. Meant to be used with Array.prototype.reduce.

    Time complexity: O(1)

    Space complexity: O(1)

    example
    const array = [5, 3];

    array.reduce(Bitwise.xor); // 6

    Parameters

    • a: number

      First operand

    • b: number

      Second operand

    Returns number

    The bitwise XOR of a and b

  • Calculate the bitwise XOR of 2 bigints. Meant to be used with Array.prototype.reduce.

    Time complexity: O(1)

    Space complexity: O(1)

    example
    const array = [5n, 3n];

    array.reduce(Bitwise.xor); // 6n

    Parameters

    • a: bigint

      First operand

    • b: bigint

      Second operand

    Returns bigint

    The bitwise XOR of a and b

Generated using TypeDoc