bitwise-flag - v2.1.0
    Preparing search index...

    Class NumberCombinatorInternal

    Implements Combinator for JavaScript's built-in number type using native 32-bit bitwise operators.

    Every operation delegates directly to JavaScript's |, &, ^, ~ and << operators, which coerce their operands to a 32-bit signed integer (Int32) before computing the result. The effective flag space is therefore 32 bits (positions 0–31), and results are always returned as signed values.

    Implements

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    zero: number = 0

    Neutral element for bitwise OR — a number with no bits set.

    Methods

    • Returns the bitwise AND of a and b.

      Parameters

      • a: number

        First operand.

      • b: number

        Second operand.

      Returns number

      a & b as a signed 32-bit integer.

    • Returns the bitwise AND of a and ~b. Same as combinator.and(a, combinator.not(b))

      Parameters

      • a: number

        First operand.

      • b: number

        Second operand.

      Returns number

      a & ~b as a signed 32-bit integer.

    • Returns the bitwise OR of a and b.

      Parameters

      • a: number

        First operand.

      • b: number

        Second operand.

      Returns number

      a | b as a signed 32-bit integer.

    • Counts the number of set bits (population count) in a.

      Reinterprets a as an unsigned 32-bit integer via >>> 0 before counting, so negative inputs are treated as their unsigned equivalent.

      Parameters

      • a: number

        Value whose set bits are counted.

      Returns number

      The count of bits set to 1 in the 32-bit unsigned representation of a.

      c.popcount(0b0111) // → 3
      c.popcount(-1) // → 32 (-1 is 0xFFFFFFFF unsigned)
    • Shifts value left by shift bit positions.

      Parameters

      • value: number

        Value to shift.

      • shift: number

        Number of positions to shift left (valid range: 0–31).

      Returns number

      value << shift as a signed 32-bit integer.

    • Returns the bitwise XOR of a and b.

      Parameters

      • a: number

        First operand.

      • b: number

        Second operand.

      Returns number

      a ^ b as a signed 32-bit integer.